小規模プログラム開発のエンタープライズ展示
この WeChat ミニ プログラム開発チュートリアルでは、WeChat ミニ プログラムを使用して企業内プロモーションや表示などの機能を開発する方法を紹介します。
1. ミニ プログラムの主要部分
ミニ プログラムの主要部分は、次の 3 つのファイルで構成され、プロジェクトのルート ディレクトリに配置する必要があります。
1.
App({ onLaunch: function() { // Do something initial when launch. }, onShow: function() { // Do something when show. }, onHide: function() { // Do something when hide. }, globalData: 'fangbei'})
2. ミニプログラムの公開設定
主に5つのページを登録し、タブバーに3つのページを表示します
{ "pages": [ "pages/index/index", "pages/news/news", "pages/news/news-details", "pages/product/product", "pages/contact/contact" ], "window": { "navigationBarTextStyle": "black", "navigationBarTitleText": "盛世华安", "navigationBarBackgroundColor": "#fbf9fe", "backgroundColor": "#fbf9fe" }, "tabBar": { "color": "#dddddd", "selectedColor": "#459ae9", "borderStyle": "black", "backgroundColor": "#ffffff", "list": [{ "pagePath": "pages/index/index", "iconPath": "images/index.png", "selectedIconPath": "images/index_selected.png", "text": "公司盛况" }, { "pagePath": "pages/product/product", "iconPath": "images/product.png", "selectedIconPath": "images/product_selected.png", "text": "产品服务" }, { "pagePath": "pages/contact/contact", "iconPath": "images/contact.png", "selectedIconPath": "images/contact_selected.png", "text": "联系我们" }] }, "networkTimeout": { "request": 10000, "connectSocket": 10000, "uploadFile": 10000, "downloadFile": 10000 }, "debug": true}
3. ビジネスページ部分
2. アプレットページは主に以下のファイルで構成されています。
このプロジェクトプログラムは、ホームページ、ニュース詳細ページ、製品サービスページ、お問い合わせページの4つのページに分かれています。
ホームページ部分
ホームページのレンダリングは次のとおりです
1. ページ構造
上部は
写真カルーセル、中央はニュースリスト、その下には詳細ビューナビゲーションがありますそのページの構造 コードは次のとおりです
@import 'style/weui.wxss'; @import "/utils/wxParse/wxParse.wxss"; page { background-color: #fbf9fe; height: 100%; }.container { display: flex; flex-direction: column; min-height: 100%; justify-content: space-between; }.page-header { display: flex; font-size: 32rpx; color: #aaa; margin-top: 50rpx; flex-direction: column; align-items: center; }.page-header-text { padding: 20rpx 40rpx; }.page-header-line { width: 150rpx; height: 1px; border-bottom: 1px solid #ccc; }.page-body { width: 100%; display: flex; flex-direction: column; align-items: center; flex-grow: 1; overflow-x: hidden; }.page-body-wrapper { margin-top: 100rpx; display: flex; flex-direction: column; align-items: center; width: 100%; }.page-body-wrapper form { width: 100%; }.page-body-wording { text-align: center; padding: 200rpx 100rpx; }.page-body-info { display: flex; flex-direction: column; align-items: center; background-color: #fff; margin-bottom: 50rpx; width: 100%; padding: 50rpx 0 150rpx 0; }.page-body-title { margin-bottom: 100rpx; font-size: 32rpx; }.page-body-text { font-size: 30rpx; line-height: 26px; color: #ccc; }.page-body-text-small { font-size: 24rpx; color: #000; margin-bottom: 100rpx; }.page-body-form { width: 100%; background-color: #fff; display: flex; flex-direction: column; width: 100%; border: 1px solid #eee; }.page-body-form-item { display: flex; align-items: center; margin-left: 30rpx; border-bottom: 1px solid #eee; height: 88rpx; font-size: 34rpx; }.page-body-form-key { width: 180rpx; color: #000; }.page-body-form-value { flex-grow: 1; }.page-body-form-value .input-placeholder { color: #b2b2b2; }.page-body-form-picker { display: flex; justify-content: space-between; height: 100rpx; align-items: center; font-size: 36rpx; margin-left: 20rpx; padding-right: 20rpx; border-bottom: 1px solid #eee; }.page-body-form-picker-value { color: #ccc; }.page-body-buttons { width: 100%; }.page-body-button { margin: 25rpx; }.page-body-button image { width: 150rpx; height: 150rpx; }.page-footer { text-align: center; color: #1aad19; font-size: 24rpx; margin: 20rpx 0; }.green{ color: #09BB07; }.red{ color: #F76260; }.blue{ color: #10AEFF; }.yellow{ color: #FFBE00; }.gray{ color: #C9C9C9; }.strong{ font-weight: bold; }.bc_green{ background-color: #09BB07; }.bc_red{ background-color: #F76260; }.bc_blue{ background-color: #10AEFF; }.bc_yellow{ background-color: #FFBE00; }.bc_gray{ background-color: #C9C9C9; }.tc{ text-align: center; }.page input{ padding: 20rpx 30rpx; background-color: #fff; }checkbox, radio{ margin-right: 10rpx; }.btn-area{ padding: 10px 30px; }.btn-area button{ margin-top: 20rpx; margin-bottom: 20rpx; }.page { min-height: 100%; flex: 1; background-color: #FBF9FE; font-size: 32rpx; font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; overflow: hidden; }.pagehd{ padding: 50rpx 50rpx 100rpx 50rpx; text-align: center; }.pagetitle{ display: inline-block; padding: 20rpx 40rpx; font-size: 32rpx; color: #AAAAAA; border-bottom: 1px solid #CCCCCC; }.pagedesc{ display: none; margin-top: 20rpx; font-size: 26rpx; color: #BBBBBB; }page{ background-color: #F8F8F8; font-size: 16px; font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; }.pagehd { padding: 40px; }.pagebd { padding-bottom: 40px; }.pagebd_spacing { padding-left: 15px; padding-right: 15px; }.pageft{ padding-bottom: 10px; text-align: center; }.pagetitle { text-align: left; font-size: 20px; font-weight: 400; }.pagedesc { margin-top: 5px; color: #888888; text-align: left; font-size: 14px; }.swiper { width: 100%; height: 400rpx; }.slide-image { width: 100%; }.news { padding: 26rpx 40rpx 26rpx 40rpx; }.news-title { color: #AAAAAA; }.news-item { margin: 10rpx 0 10rpx 0; background-color: #fff; }.news-item-pic { padding: 20rpx 0 10rpx 20rpx; width: 160rpx; float: left; }.news-item-image { width: 100%; }.news-item-words { width: 450rpx; height: 65px; float: right; overflow-y: hidden; padding: 20rpx 10rpx; }.news-item-title { font-size: 11pt; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.news-item-content { font-size: 8pt; line-height: 13pt; text-overflow:ellipsis; color: #a9a9a9; }.news-more { color: #AAAAAA; font-size: 14px; }.news-more-line { padding-left: -26rpx important; }.news-details-content { padding: 0 40rpx 100rpx 40rpx; }.video { }.video-input { border: 1px solid #CCCCCC; }.contact { padding: 40rpx 40rpx 40rpx 40rpx; }image { height: auto; }
スタイルのコードは次のとおりです
<!--index.wxml--><view class="index"> <view class="slider"> <swiper class="swiper" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{swipers}}"> <swiper-item> <navigator url="/pages/news/news-details?id={{item.id}}" class="widget"> <image mode="widthFix" src="{{item.thumbnail_images.medium_large.url}}" class="slide-image" width="" height=""></image> </navigator> </swiper-item> </block> </swiper> </view> <view class="news"> <text class="news-title">新闻动态</text> <block wx:for="{{news}}"> <navigator url="/pages/news/news-details?id={{item.id}}"> <view class="news-item line"> <view class="news-item-pic"> <image mode="widthFix" src="{{item.thumbnail}}" class="news-item-image" width="" height=""></image> </view> <view class="news-item-words"> <view class="news-item-title"><text>{{item.title_plain}}</text></view> <view class="news-item-content"><text>{{item.excerpt_plain}}</text></view> </view> </view> </navigator> </block> <view class="widgetslist widgetslist_show"> <navigator url="/pages/news/news?cat={{cat}}" class="widget_more"> <text class="news-more">查看更多</text> <image class="widgetarrow" src="/images/arrowright.png" mode="aspectFill" /> <view class="widgetline widgetline_first"></view> </navigator> </view> </view></view>
インターフェース、フロントエンド表示用にスワイペット、ニュース、その他のデータに保存します
.index{ background-color: #FBF9FE; font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; flex: 1; min-height: 100%; font-size: 32rpx; }.head{ padding: 80rpx; line-height: 1; }.body{ padding-left: 30rpx; padding-right: 30rpx; overflow: hidden; }.title{ font-size: 52rpx; }.desc{ margin-top: 10rpx; color: #888888; font-size: 28rpx; }.widgetsitem{ margin-top: 20rpx; margin-bottom: 20rpx; background-color: #FFFFFF; overflow: hidden; border-radius: 4rpx; cursor: pointer; }.widgetsinfo{ display: flex; padding: 40rpx; align-items: center; flex-direction: row; }.widgetsinfo_show{ }.widgetsinfo_show .widgetsinfo-img{ transform: rotate(-90deg); }.widgetsinfo-name{ flex: 1; }.widgetsinfo-img{ width: 32rpx; height: 32rpx; transition: transform .4s; transform: rotate(90deg); }.widgetslist{ display: none; }.widgetslist_show{ display: block; }.widget{ position: relative; padding-top: 26rpx; padding-bottom: 26rpx; padding-left: 40rpx; padding-right: 40rpx; }.widget_more{ position: relative; padding-top: 26rpx; padding-bottom: 26rpx; padding-left: 0rpx; padding-right: 40rpx; }.widgetarrow{ position: absolute; top: 28rpx; right: 44rpx; width: 32rpx; height: 32rpx; }.widgetline{ content: " "; position: absolute; left: 40rpx; top: 0; right: 0; height: 2rpx; background-color: #F0F0F0; }.widgetline_first{ left: 0; right: 0; background-color: #D8D8D8; }
製品とサービスのページは、ホームページのニュースリストページに似ています
1。ページ構造ページ構造コードは以下の通りですvar CONFIG = require('../../utils/config.js') Page({ data: { indicatorDots: true, autoplay: true, interval: 5000, duration: 1000, swipers: [], news: [], cat: '17', }, onLoad: function () { var that = this; wx.request({ url: CONFIG.API_URL.GET_INDEX, method: 'GET', data: {}, header: { 'Accept': 'application/json' }, success: function(res) { console.log(res); if (res.statusCode == 200 && res.data.status == 'ok') { var data = res.data; var swipers = []; var news = []; console.log(data); for (var i = 0; i < data.count; i++) { if (i < 3) { swipers.push(data.posts[i]); } else { var excerpt_plain = data.posts[i].excerpt.replace(/<[^>].*?>/g, ""); data.posts[i].excerpt_plain = excerpt_plain.replace(/\[[^\]].*?\]/g, ""); news.push(data.posts[i]); } } that.setData({swipers: swipers}); that.setData({news: news}); } else { } } }) }, onShareAppMessage: function () { // return custom share data when user share. console.log('onShareAppMessage') return { title: '盛世华安', desc: '小程序', path: '/pages/index/index' } }, });
2. スタイルシート
は公開スタイルシートを使用します。3. ページロジック処理
公式サイトインターフェースデータのリクエストと表示<view class="news"> <text class="news-title">产品服务</text> <block wx:for="{{news}}"> <navigator url="/pages/news/news-details?id={{item.id}}"> <view class="news-item line"> <view class="news-item-pic"> <image mode="widthFix" src="{{item.thumbnail}}" class="news-item-image" width="" height=""></image> </view> <view class="news-item-words"> <view class="news-item-title"><text>{{item.title_plain}}</text></view> <view class="news-item-content"><text>{{item.excerpt_plain}}</text></view> </view> </view> </navigator> </block> </view>
var CONFIG = require('../../utils/config.js') Page({ data: { }, onLoad: function () { var that = this; wx.request({ url: CONFIG.API_URL.GET_CATEGORY + '14', method: 'GET', data: {}, header: { 'Accept': 'application/json' }, success: function(res) { console.log(res); if (res.statusCode == 200 && res.data.status == 'ok') { var data = res.data; var news = []; console.log(data); for (var i = 0; i < data.count; i++) { var excerpt_plain = data.posts[i].excerpt.replace(/<[^>].*?>/g, ""); data.posts[i].excerpt_plain = excerpt_plain.replace(/\[[^\]].*?\]/g, ""); news.push(data.posts[i]); } that.setData({news: news}); } else { } } }) }, onReady:function(){ // 页面渲染完成 }, onShow:function(){ // 页面显示 }, onHide:function(){ // 页面隐藏 }, onUnload:function(){ // 页面关闭 }, go: function(event) { wx.navigateTo({ url: '/pages/news/news-details?id=' + event.currentTarget.dataset.type }) } })
<import src="../../utils/wxParse/wxParse.wxml"/> <view class="page"> <view class="pagehd"> <text class="pagetitle"></text> <text class="pagedesc"></text> </view> <view class="news-details-content wxParse"> <template is="wxParse" data="{{wxParseData:content.nodes}}"/> </view></view>
WeChat アプレットの完全なソースコードのダウンロード2 .
WeChat ミニ プログラム デモ: Yangtao
以上が小規模プログラム開発のエンタープライズ展示の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











ミニ プログラム開発における PHP の権限管理とユーザー ロール設定 ミニ プログラムの普及と適用範囲の拡大に伴い、ユーザーからはミニ プログラムの機能とセキュリティに対する要求が高まっています。その中でも権限管理とユーザー ロール設定は、ミニ プログラムのセキュリティを確保する上で重要な部分です。ミニプログラムでの権限管理やユーザーロールの設定にPHPを利用することで、ユーザーのデータやプライバシーを効果的に保護することができますので、その実装方法を紹介します。 1. 権限管理の実装 権限管理とは、ユーザーの ID と役割に基づいてさまざまな操作権限を付与することを指します。小さくて

ミニ プログラム開発における PHP のページ ジャンプとルーティング管理 ミニ プログラムの開発が急速に進むにつれ、PHP とミニ プログラム開発を組み合わせる開発者が増えています。小規模プログラムの開発では、ページ ジャンプとルーティング管理は非常に重要な部分であり、開発者がページ間の切り替えやナビゲーション操作を実現するのに役立ちます。一般的に使用されるサーバーサイド プログラミング言語として、PHP はミニ プログラムと適切に対話し、データを転送できます。ミニ プログラムにおける PHP のページ ジャンプとルーティング管理について詳しく見てみましょう。 1. ページジャンプベース

uni-app でミニ プログラムを開発および公開する方法 モバイル インターネットの発展に伴い、ミニ プログラムはモバイル アプリケーション開発の重要な方向性になりました。クロスプラットフォーム開発フレームワークとして、uni-app は WeChat、Alipay、Baidu などの複数の小規模プログラム プラットフォームの開発を同時にサポートできます。以下では、uni-app を使用して小さなプログラムを開発および公開する方法を詳しく紹介し、具体的なコード例をいくつか示します。 1. 小さなプログラムを開発する前の準備. uni-app を使用して小さなプログラムを開発する前に、いくつかの準備を行う必要があります。

ミニ プログラム開発における PHP のセキュリティ保護と攻撃の防止 モバイル インターネットの急速な発展に伴い、ミニ プログラムは人々の生活の重要な部分になりました。 PHP は、強力で柔軟なバックエンド開発言語として、小規模プログラムの開発にも広く使用されています。ただし、セキュリティの問題は、プログラム開発において常に注意が必要な側面です。この記事では、小規模プログラム開発における PHP のセキュリティ保護と攻撃防止に焦点を当て、いくつかのコード例を示します。 XSS (クロスサイト スクリプティング攻撃) の防止 XSS 攻撃とは、ハッカーが Web ページに悪意のあるスクリプトを挿入することを指します。

ミニ プログラム開発における PHP データ キャッシュとキャッシュ戦略 ミニ プログラムの急速な開発に伴い、より多くの開発者がミニ プログラムのパフォーマンスと応答速度を向上させる方法に注目し始めています。重要な最適化方法の 1 つは、データ キャッシュを使用してデータベースや外部インターフェイスへの頻繁なアクセスを減らすことです。 PHP では、さまざまなキャッシュ戦略を使用してデータ キャッシュを実装できます。この記事では、PHP におけるデータ キャッシュの原理を紹介し、いくつかの一般的なキャッシュ戦略のサンプル コードを提供します。 1. データ キャッシュの原理 データ キャッシュとは、データをメモリに保存することを指します。

今日は、PHP で開発されたドロップダウン メニューを WeChat アプレットに実装する方法を学びます。 WeChat ミニ プログラムは、ユーザーがダウンロードしてインストールすることなく WeChat で直接使用できる軽量のアプリケーションであり、非常に便利です。 PHP は非常に人気のあるバックエンド プログラミング言語であり、WeChat ミニ プログラムとうまく連携する言語です。 PHP を使用して WeChat ミニ プログラムのドロップダウン メニューを開発する方法を見てみましょう。まず、PHP、WeChat アプレット開発ツール、サーバーなどの開発環境を準備する必要があります。それから私たちは

ミニ プログラム開発における PHP ページ アニメーション効果とインタラクション デザインの概要: ミニ プログラムは、モバイル デバイス上で実行され、ネイティブ アプリケーションと同様のエクスペリエンスを提供できるアプリケーションです。ミニ プログラムの開発では、一般的に使用されるバックエンド言語として PHP を使用して、ミニ プログラム ページにアニメーション効果やインタラクティブなデザインを追加できます。この記事では、一般的に使用される PHP ページのアニメーション効果とインタラクション デザインをいくつか紹介し、コード例を添付します。 1. CSS3 アニメーション CSS3 は、さまざまなアニメーション効果を実現するための豊富なプロパティとメソッドを提供します。そして小さいところでは

UniApp によって実装された ByteDance アプレットの開発と起動プロセスの分析 ByteDance アプレットは、新しいモバイル アプリケーション開発方法として、業界で徐々に人気が高まっています。 Bytedance ミニ プログラムを開発する前に、UniApp を使用して開発および起動プロセスを実装する方法を理解する必要があります。 1. UniApp の紹介 UniApp は、Vue.js をベースに開発されたフレームワークで、HTML5、アプリ、小規模プログラムなどを複数端末の統合開発フレームワークとして記述し、コードを記述することで複数のプラットフォームで同時に動作させることができます。 、フォントも含めて。
