微信小程序的index.js怎么写?详细代码见下方↓

已知index.js里有如下page中的代码:

Page({
data: {
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
game_list:[
{
id: 0 ,
imgurl:'http://xxx.com/games/1s/icon.png',
name:'游戏1',
players:39871,
gamesuburl:'1s'
}
]
},
其中gamelist还有其他item单元,下方需要遍历调用game_list中的gamesuburl, 其中???的部分怎么写?
onProductsItemTap:function(){
wx.navigateTo({
url: '../games/' + ???
})
},

微信小程序实例index.js代码如下:

可以搜索小程序名称: 快递最后一公里

实例index.js代码

var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {

   //三张图片轮播
imgUrls: [
{
imageUrl: '/images/weicha/timg1.jpg',
},
{
imageUrl: '/images/weicha/timg2.jpg',
},
{
imageUrl: '/images/weicha/timg3.jpg',
}
],
indicatorDots: false,
autoplay: false,
interval: 5000,
duration: 800,
},
onSwiperTab: function (e) {
/*var postId = e.target.dataset.postId;
wx.navigateTo({
url: postId,
});*/
},

  /**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
app.loginWinCha(this.initPageData);
},
//初始化登录才能查看的数据
initPageData: function () {
this.setData({
componentList: [
{
id: 1,
url: '../weicha/express/courier/index',
imageUrl: '/images/weicha/timg1_1.jpg',
title: '快递小哥(送快递)',
queryType: 'courier'
},
{
id: 2,
url: '../weicha/express/seller/index',
imageUrl: '/images/weicha/timg1_2.jpg',
title: '合作商家(代收快递)',
queryType: 'seller'
},
{
id: 3,
url: '../weicha/express/personal/index',
imageUrl: '/images/weicha/timg1_3.jpg',
title: '收件人(签收快递)'
},
{
id: 4,
url: '../weicha/express/logistics/index',
imageUrl: '/images/weicha/timg1_4.jpg',
title: '快递物流查询'
}
]
});
},
onItemClick: function (e) {
var targetUrl = e.currentTarget.dataset.pay;
var targetQueryType = e.currentTarget.dataset.index;
if (targetQueryType == "seller") {
var reqData = {
seller_openId: app.globalData.openid,
status: '2'
};
this.queryDBUtil("sellerInfo", reqData, targetQueryType, targetUrl,
"亲,您暂未申请商家,请提交商家申请!");
} else if (targetQueryType == "courier") {
var reqData = {
courier_openId: app.globalData.openid,
status: '2'
};
this.queryDBUtil("courierInfo", reqData, targetQueryType, targetUrl,
"亲,您暂未申请快递员,请提交快递员申请!");;
} else {
wx.navigateTo({
url: targetUrl
});
}
},
queryDBUtil: function (reqCollectionName, reqData,queryType, retUrl,retMgs){
wx.cloud.callFunction({
name: "utilsDB",
data: {
collectionName: reqCollectionName,
collectionWhere: reqData
},
complete: res => {
let retStatus = '1';
if (res.result.data.length >= 1) {
retStatus = res.result.data[0].status;
}
if (retStatus == '2') {
if (queryType == "seller"){
app.globalData.seller = res.result.data[0];
} else if (queryType == "courier"){
app.globalData.courier = res.result.data[0];
}
wx.navigateTo({
url: retUrl
});
} else {
wx.showToast({
icon: 'none',
title: retMgs
});
}
},
fail: err => {
wx.showToast({
icon: 'none',
title: retMgs
});
}
});
}

})

温馨提示:答案为网友推荐,仅供参考