この WeChat ミニ プログラム開発チュートリアルでは、WeChat ミニ プログラムを使用して人気の映画やプレビュー機能を開発する方法を紹介します。
この記事は主に、ミニプログラムの本編と映画のホームページと詳細ページの2つの部分に分かれています
1. ミニプログラムの本編
ミニプログラムの本編は3つのファイルで構成されていますは、次のようにプロジェクトのルート ディレクトリに配置する必要があります:
App({ onLaunch: function() { // Do something initial when launch. }, onShow: function() { // Do something when show. }, onHide: function() { // Do something when hide. }, globalData: 'I am global data'})2. ミニ プログラムの公開設定 主に人気の映画のホームページと詳細ページの 2 つのページを登録します。
{ "pages":[ "pages/index/index", "pages/details/details" ], "window":{ "backgroundTextStyle":"light", "navigationBarBackgroundColor": "#FF4D64", "navigationBarTitleText": "热门电影", "backgroundColor":"#FFF", "navigationBarTextStyle":"white" } }2. ムービーページ部分 ミニプログラムページ 主に以下のファイルで構成されています。
<loading> 加载中...</loading><scroll-view> <navigator> <view><image></image><image></image></view> <view> <view> <text>{{item.nm}}</text> <test>3Dimax</test> <test>3d</test> <test>imax</test> <test>2d</test> </view> <view><view><view></view></view>{{item.sc}}</view> <view><text>{{item.wish}}人想看</text>{{item.showInfo}}</view> <view>{{item.scm}}</view> <view>{{item.dir}} {{item.star}}</view> <view><text>购票</text><text>预售</text></view> </view> </navigator></scroll-view>
2. スタイルシート
スタイルコードは次のとおりです/**index.wxss**/.flex-box{ display: flex; }.flex-btn{ flex: 1; }.list{ border-bottom: 1rpx solid #e5e5e5; padding: 30rpx; }.list-img{ width: 130rpx; height: 180rpx; margin-right: 20rpx; position: relative; }.list-img .img{ width: 130rpx; height: 180rpx; }.list-play{ position: absolute; left: 45rpx; top: 70rpx; width: 40rpx; height: 40rpx; }.list-title{ height: 52rpx; }.list-title text{ font-size: 18px; line-height: 52rpx; color: #000; }.i-imax{ width: 52rpx; height: 28rpx; margin-left: 10rpx; }.list-size{ height: 40rpx; font-size: 14px; color: #8a869e; }.list-size .star{ width: 100rpx; height: 20rpx; background: url(../../images/i-star.png) no-repeat; background-size: 100rpx; display: inline-block; margin-right: 10rpx; }.stars{ width: 100rpx; height: 20rpx; background: url(../../images/i-stars.png) no-repeat; background-size: 100rpx; float: left; margin-right: 10rpx; }.list-brief{ font-size: 12px; line-height: 48rpx; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 400rpx; }.list-brief .wish{ color: #108ee9; border-right: 1rpx solid #666; padding-right: 10rpx; margin-right: 10rpx; }.list-main{ position: relative; }.list-sale{ position: absolute; right: 10rpx; top: 70rpx; }.list-sale text{ padding: 10rpx 18rpx; border: 1rpx solid #37b7ff; font-size: 14px; color: #37b7ff; border-radius: 6rpx; }.list-sale .pre-sale{ border: 1rpx solid #fea54c; color: #fea54c; }
3. ページロジックの処理
//index.jsPage({ data: { films: [], limit: 6, loading: false, windowHeight: 0, windowWidth: 0 }, onLoad: function () { this.setData({ loading: false }) }, onShow: function(){ var that = this wx.request({ url: 'http://m.maoyan.com/movie/list.json', //仅为示例,并非真实的接口地址 data: { offset: 0, type: 'hot', limit: that.data.limit }, header: { 'Content-Type': 'application/json' }, success: function(res) { console.log(res.data) that.setData({ films: res.data.data.movies, loading: true }) } }) wx.getSystemInfo({ success: (res) => { that.setData({ windowHeight: res.windowHeight, windowWidth: res.windowWidth }) } }) }, pullDownRefresh: function(e) { this.onLoad() }, pullUpLoad: function(e) { var limit = this.data.limit + 6 console.log(limit) this.setData({ limit: limit }) this.onShow() } })ここでは Maoyan Movie の
api が使用されます。そのインターフェイスは次のとおりです:
m.maoyan.com/movie/list.json詳細ページ部分
1.構造
このページ構造では、ビュー
に映画に関する一般的な情報が表示されるほか、プレビュービデオ
機能が使用されます。{ "control":{ "expires":1800 }, "status":0, "data":{ "hasNext":true, "movies":[ { "showInfo":"今天64家影院放映1083场", "cnms":0, "sn":0, "late":false, "img":"http://p0.meituan.net/165.220/movie/fbe5f97c016c9f4520109dc70f458d4d83363.jpg", "sc":9.1, "ver":"2D/3D/IMAX 3D/中国巨幕", "rt":"本周五上映", "dur":136, "nm":"银河护卫队2", "showDate":"", "src":"", "vd":"", "dir":"詹姆斯·古恩", "star":"克里斯·帕拉特,佐伊·索尔达娜,戴夫·巴蒂斯塔", "cat":"动作,冒险,科幻", "wish":154543, "3d":true, "pn":188, "scm":"星爵身世迷,终于见爹地", "preSale":0, "imax":true, "snum":41866, "time":"", "id":248683 }, { "showInfo":"今天62家影院放映335场", "cnms":0, "sn":0, "late":false, "img":"http://p0.meituan.net/165.220/movie/aeb864fa21d578d845b9cefc056e40cb2874891.jpg", "sc":9.8, "ver":"2D", "rt":"本周五上映", "dur":140, "nm":"摔跤吧!爸爸", "showDate":"", "src":"", "vd":"", "dir":"尼特什·提瓦瑞", "star":"阿米尔·汗,萨卡诗·泰瓦,法缇玛·萨那·纱卡", "cat":"喜剧,动作,家庭", "wish":27412, "3d":false, "pn":54, "scm":"为圆摔跤梦,女儿不心疼", "preSale":0, "imax":false, "snum":19166, "time":"", "id":588362 }, { "showInfo":"今天63家影院放映256场", "cnms":0, "sn":0, "late":false, "img":"http://p1.meituan.net/165.220/movie/cc50791238502ae1fa08df764c5f5c97223987.jpg", "sc":9.1, "ver":"2D/中国巨幕", "rt":"2017-04-28上映", "dur":120, "nm":"拆弹·专家", "showDate":"", "src":"", "vd":"", "dir":"邱礼涛", "star":"刘德华,姜武,宋佳", "cat":"动作,悬疑,犯罪", "wish":49007, "3d":false, "pn":167, "scm":"爆炸袭击案,拆弹反恐难", "preSale":0, "imax":false, "snum":95491, "time":"", "id":346103 }, { "showInfo":"今天48家影院放映156场", "cnms":0, "sn":0, "late":false, "img":"http://p1.meituan.net/165.220/movie/af297f59e363ce96290dfea22f6fea0c153020.jpg", "sc":9.4, "ver":"2D/3D/IMAX 3D/中国巨幕/全景声", "rt":"2017-04-14上映", "dur":136, "nm":"速度与激情8", "showDate":"", "src":"", "vd":"", "dir":"F·加里·格雷", "star":"范·迪塞尔,杰森·斯坦森,道恩·强森", "cat":"动作,惊悚,犯罪", "wish":320713, "3d":true, "pn":226, "scm":"车王要黑化,家族被击垮", "preSale":0, "imax":true, "snum":899592, "time":"", "id":248700 }, { "showInfo":"今天46家影院放映133场", "cnms":0, "sn":0, "late":false, "img":"http://p1.meituan.net/165.220/movie/ea0131b3e9e40f226c7c2664f6185a3792752.jpg", "sc":8.9, "ver":"2D", "rt":"2017-04-27上映", "dur":107, "nm":"喜欢·你", "showDate":"", "src":"", "vd":"", "dir":"许宏宇", "star":"金城武,周冬雨,孙艺洲", "cat":"喜剧,爱情", "wish":30224, "3d":false, "pn":216, "scm":"美食嘉年华,爱情甜掉牙", "preSale":0, "imax":false, "snum":68306, "time":"", "id":672175 } ] } }2. スタイルシートスタイルコードは以下の通り
<loading>
加载中...</loading><view>
<view><image></image><image></image></view>
<view>
<view>
<text>{{films.MovieDetailModel.nm}}</text>
<image></image>
<image></image>
</view>
<view>{{films.MovieDetailModel.scm}}</view>
<view>{{films.MovieDetailModel.cat}}</view>
<view>{{films.MovieDetailModel.src}} / {{films.MovieDetailModel.dur}}分钟</view>
<view>{{films.MovieDetailModel.rt}}</view>
<view><text>{{films.MovieDetailModel.wish}}人想看</text>{{films.MovieDetailModel.showInfo}}</view>
<view><view><view></view></view>{{films.MovieDetailModel.sc}}</view>
</view>
<image></image><video></video></view><scroll-view><view>{{details}}</view></scroll-view><button>立即购票 </button>
インターフェイスは/**index.wxss**/.flex-box{
display: flex;
}.flex-btn{
flex: 1;
}.detail{
border-bottom: 1rpx solid #e5e5e5;
padding: 30rpx 30rpx 0 30rpx;
overflow: hidden;
position: relative;
}.video-hide{
display: none;
}.video-show{
display: block;
position: absolute;
width: 750rpx;
height: 406rpx;
top: 0;
left: 0;
}.bg{
position: absolute;
left: 0;
top: 0;
width: 750rpx;
height: 1048rpx;
z-index: -1;
}.detail-img{
width: 236rpx;
height: 376rpx;
margin-right: 20rpx;
position: relative;
}.detail-img .img{
width: 236rpx;
height: 376rpx;
}.detail-play{
position: absolute;
left: 70rpx;
top: 130rpx;
width: 80rpx;
height: 80rpx;
}.detail-title{
height: 70rpx;
}.detail-title text{
font-size: 18px;
line-height: 70rpx;
color: #FFF;
}.i-imax{
width: 52rpx;
height: 28rpx;
margin-left: 10rpx;
}.detail-size{
height: 40rpx;
font-size: 14px;
color: #FFF;
}.detail-size .star{
width: 100rpx;
height: 20rpx;
background: url(../../images/i-star.png) no-repeat;
background-size: 100rpx;
display: inline-block;
margin-right: 10rpx;
}.stars{
width: 100rpx;
height: 20rpx;
background: url(../../images/i-stars.png) no-repeat;
background-size: 100rpx;
float: left;
margin-right: 10rpx;
}.detail-brief{
font-size: 14px;
line-height: 50rpx;
color: #FFF;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 400rpx;
}.detail-brief .wish{
color: #FFF;
border-right: 1rpx solid #666;
padding-right: 10rpx;
margin-right: 10rpx;
}.detail-main{
position: relative;
}.detail-sale{
position: absolute;
right: 10rpx;
top: 70rpx;
}.detail-sale text{
padding: 10rpx 18rpx;
border: 1rpx solid #37b7ff;
font-size: 14px;
color: #37b7ff;
border-radius: 6rpx;
}.detail-sale .pre-sale{
border: 1rpx solid #fea54c;
color: #fea54c;
}.details-dra view{
margin: 23rpx;
color: #333;
font-size: 14px;
line-height: 20px;
}
248683は映画IDです
返されるデータは次のとおりです:
//index.jsPage({ data: { films: [], loading: false, title: '正在热映', video: 'video-hide', datails: '', windowWidth: 0 }, onLoad: function (options) { var id = 'http://m.maoyan.com/movie/' + options.id + '.json' this.setData({ title: options.titles }) var that = this wx.request({ url: id, //仅为示例,并非真实的接口地址 data: { }, header: { 'Content-Type': 'application/json' }, success: function(res) { console.log(res.data) that.setData({ films: res.data.data, loading: true }) var pages = that.data.films.MovieDetailModel.dra pages = pages.replace(/<.>/ig,"") that.setData({ details: pages }) console.log(pages) } }) }, onReady: function(){ var that = this wx.setNavigationBarTitle({ title: that.data.title }) wx.getSystemInfo({ success: (res) => { that.setData({ windowHeight: res.windowHeight, windowWidth: res.windowWidth }) } }) }, pay: function(){ console.log('pay'); wx.requestPayment({ 'timeStamp': '', 'nonceStr': '', 'package': '', 'signType': 'MD5', 'paySign': '', 'success':function(res){ console.log('success'); }, 'fail':function(res){ console.log('fail'); } }) }, vShow: function(){ this.setData({ video: 'video-show' }) }, vHid: function(){ this.setData({ video: 'video-hide' }) } })</.>
3. プログラムレンダリング
【関連する推奨事項】1.
WeChatアカウント プログラムが完成しました ソースコードのダウンロード2.
以上が小規模なプログラム開発に人気の映画の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

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

WebStorm Mac版
便利なJavaScript開発ツール

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

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

Dreamweaver Mac版
ビジュアル Web 開発ツール
