var WxParse = require('components/wxParse/wxParse.js');
var util = require('utils/util.js');
App({
onLaunch: function () {
let userInfo;
if (userInfo = wx.getStorageSync('userInfo')) {
this.globalData.userInfo = userInfo;
}
this.appInitial();
},
appInitial: function () {
let that = this;
this._getSystemInfo({
success: function (res) {
that.setSystemInfoData(res);
}
});
wx.request({
url: this.globalData.siteBaseUrl +'/index.php?r=AppUser/MarkWxXcxStatus',
data: {
app_id: this.getAppId(),
his_id: this.globalData.historyDataId
},
method: 'GET',
header: {
'content-type': 'application/json'
}
});
},
onShow: function (options) {
if (!this.globalData.appOptions) {
this.globalData.appOptions = options
}
let that = this;
if (options && options.scene && ([1011, 1012, 1013, 1007, 1008].indexOf(options.scene) > -1)){
if(options.query.location_id){
this.globalData.urlLocationId = options.query.location_id;
}
if (options.query.user_token) {
this._getPromotionUserToken({
user_token: options.query.user_token
});
}
if (options.query.leader_user_token) {
that.showModal({
content: '是否要成为推广人员的团员',
showCancel: true,
confirm: function () {
that._getPromotionUserToken({
leader_user_token: options.query.leader_user_token
});
}
})
}
if (options.query.needStatistics == 1 && options.query.statisticsType) {
let detail = options.query.detail;
let param = "";
let params = {};
let objId = (options.query.statisticsType != 9 && options.query.statisticsType != 10) ? (options.query.statisticsType == 11 ? options.path.split('/')[2] : detail) : options.query.statisticsType
if (options.query.statisticsType == 9 || options.query.statisticsType == 10) {
params = {
obj_id: options.query.statisticsType,
type: options.query.statisticsType
}
} else if (options.query.statisticsType == 11) {
let newOption = Object.assign({}, options.query)
delete newOption.needStatistics;
delete newOption.statisticsType;
for (let i in newOption) {
param += '&' + i + '=' + newOption[i]
}
params = {
obj_id: objId,
type: 11,
params: param
}
}
that.sendRequest({
hideLoading: true,
url: '/index.php?r=AppShop/AddQRCodeStat',
method: 'POST',
data: params
})
}
}
if (options && options.scene && ([1011, 1012, 1013, 1007, 1008, 1047, 1048, 1049].indexOf(options.scene) > -1)){
if(options.query.p_u){
that.globalData.p_u = options.query.p_u;
}
}
},
_getPromotionUserToken: function (param) {
let that = this;
this.sendRequest({
hideLoading: true,
url: '/index.php?r=AppDistribution/userBind',
method: 'post',
data: param,
success: function (res) {
that.setPageTitle(res.data.nickname);
},
successStatusAbnormal: function (res) {
if(res.status == 99){
let homepageRouter = that.getHomepageRouter();
that.turnToPage('/pages/' + homepageRouter + '/' + homepageRouter, true);
}
if (res.status == 100){
that.turnToPage('/promotion/pages/promotionApply/promotionApply', true);
}
}
});
},
_getSystemInfo: function (options) {
wx.getSystemInfo({
success: function (res) {
typeof options.success === 'function' && options.success(res);
},
fail: function (res) {
typeof options.fail === 'function' && options.fail(res);
},
complete: function (res) {
typeof options.complete === 'function' && options.complete(res);
}
});
},
sendRequest: function (param, customSiteUrl) {
let that = this;
let data = param.data || {};
let header = param.header;
let requestUrl;
if(data.app_id){
data._app_id = data.app_id;
} else {
data._app_id = data.app_id = this.getAppId();
}
if(!this.globalData.notBindXcxAppId){
data.session_key = this.getSessionKey();
}
if(customSiteUrl) {
requestUrl = customSiteUrl + param.url;
} else {
requestUrl = this.globalData.siteBaseUrl + param.url;
}
if(param.method){
if(param.method.toLowerCase() == 'post'){
data = this._modifyPostParam(data);
header = header || {
'content-type': 'application/x-www-form-urlencoded;'
}
}
param.method = param.method.toUpperCase();
}
if(!param.hideLoading){
this.showToast({
title: '请求中...',
icon: 'loading'
});
}
wx.request({
url: requestUrl,
data: data,
method: param.method || 'GET',
header: header || {
'content-type': 'application/json'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) {
that.hideToast();
that.showModal({
content: ''+res.errMsg
});
typeof param.successStatusAbnormal == 'function' && param.successStatusAbnormal(res.data);
return;
}
if (res.data.status) {
if (res.data.status == 2 || res.data.status == 401) {
that.goLogin({
success: function () {
that.sendRequest(param, customSiteUrl);
},
fail: function () {
typeof param.successStatusAbnormal == 'function' && param.successStatusAbnormal(res.data);
}
});
return;
}
if (res.data.status != 0) {
that.hideToast();
that.showModal({
content: ''+res.data.data,
confirm : function() {
typeof param.successShowModalConfirm == 'function' && param.successShowModalConfirm(res.data);
}
});
typeof param.successStatusAbnormal == 'function' && param.successStatusAbnormal(res.data);
return;
}
}
typeof param.success == 'function' && param.success(res.data);
},
fail: function (res) {
that.hideToast();
switch(res.errMsg){
case 'request:fail url not in domain list': res.errMsg = '请配置正确的请求域名'; break;
default: break;
}
that.showModal({
content: '请求失败 '+res.errMsg
})
typeof param.fail == 'function' && param.fail(res.data);
},
complete: function (res) {
param.hideLoading || that.hideToast();
typeof param.complete == 'function' && param.complete(res.data);
}
});
},
_modifyPostParam: function (obj) {
let query = '';
let name, value, fullSubName, subName, subValue, innerObj, i;
for(name in obj) {
value = obj[name];
if(value instanceof Array) {
for(i=0; i < value.length; ++i) {
subValue = value[i];
fullSubName = name + '[' + i + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += this._modifyPostParam(innerObj) + '&';
}
} else if (value instanceof Object) {
for(subName in value) {
subValue = value[subName];
fullSubName = name + '[' + subName + ']';
innerObj = {};
innerObj[fullSubName] = subValue;
query += this._modifyPostParam(innerObj) + '&';
}
} else if (value !== undefined && value !== null) {
query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
}
}
return query.length ? query.substr(0, query.length - 1
没有合适的资源?快使用搜索试试~ 我知道了~
商超小程序(附代码)
需积分: 50 28 下载量 126 浏览量
2018-05-08
14:55:11
上传
评论 4
收藏 340KB GZ 举报
温馨提示
共202个文件
js:53个
wxss:49个
json:47个
商超小程序(tp后台)商品分类 ,轮播图 ,会员 , 优惠券
资源推荐
资源详情
资源评论
收起资源包目录
商超小程序(附代码) (202个子文件)
app.js 257KB
page10027.js 34KB
UuGLFHhAhG_page10000.js 29KB
page10034.js 28KB
page10046.js 28KB
page10028.js 25KB
page10024.js 22KB
page10032.js 22KB
page10031.js 22KB
goodsDetail.js 21KB
previewGoodsOrder.js 20KB
page10029.js 20KB
page10035.js 20KB
page10055.js 20KB
page10038.js 19KB
page10041.js 19KB
page10045.js 19KB
page10042.js 19KB
orderDetail.js 19KB
page10054.js 19KB
page10033.js 18KB
page10044.js 13KB
shoppingCart.js 12KB
tabbarShoppingCart.js 12KB
searchAddress.js 11KB
goodsOrderDetail.js 10KB
myOrder.js 10KB
advanceSearch.js 9KB
tabbarMyOrder.js 9KB
bindCellphone.js 7KB
wxDiscode.js 7KB
html2json.js 7KB
goodsOrderPaySuccess.js 6KB
myAddress.js 6KB
transferPage.js 6KB
scratch.js 5KB
htmlparser.js 5KB
goodsAdditionalInfo.js 5KB
addAddress.js 5KB
makeComment.js 4KB
transferOrderDetail.js 4KB
announce.js 4KB
wxParse.js 4KB
pageQRCode.js 3KB
verificationCodePage.js 2KB
extensionPage.js 2KB
goodsComment.js 2KB
util.js 2KB
transferPaySuccess.js 1KB
shopVipModal.js 649B
rewardPointModal.js 604B
backToHomePage.js 396B
logisticsPage.js 370B
app.json 2KB
page10045.json 413B
page10041.json 413B
page10035.json 402B
page10038.json 402B
page10029.json 402B
page10031.json 401B
page10034.json 401B
page10032.json 395B
page10042.json 395B
page10044.json 395B
page10054.json 395B
page10046.json 395B
page10024.json 386B
page10055.json 386B
page10033.json 383B
UuGLFHhAhG_page10000.json 383B
page10027.json 383B
page10028.json 383B
goodsDetail.json 214B
goodsOrderPaySuccess.json 160B
advanceSearch.json 159B
myOrder.json 152B
transferPaySuccess.json 147B
makeComment.json 146B
rewardPointModal.json 48B
shopVipModal.json 48B
logisticsPage.json 42B
tabbarMyOrder.json 42B
goodsComment.json 42B
orderDetail.json 42B
previewGoodsOrder.json 42B
goodsOrderDetail.json 42B
goodsAdditionalInfo.json 42B
addAddress.json 42B
transferOrderDetail.json 42B
searchAddress.json 42B
myAddress.json 42B
bindCellphone.json 42B
transferPage.json 39B
shoppingCart.json 39B
tabbarShoppingCart.json 39B
verificationCodePage.json 38B
extensionPage.json 36B
pageQRCode.json 25B
backToHomePage.json 25B
announce.json 25B
共 202 条
- 1
- 2
- 3
资源评论
qq_33704814
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功