var WxParse = require('components/wxParse/wxParse.js');
var util = require('utils/util.js');
App({
onLaunch: function () {
var userInfo;
if(userInfo = wx.getStorageSync('userInfo')){
this.globalData.userInfo = userInfo;
}
this.getSystemInfo();
},
getSystemInfo : function() {
var that = this;
wx.getSystemInfo({
success: function(res) {
that.systemInfo = res;
}
});
},
sendRequest: function(param, customSiteUrl){
var that = this,
data = param.data || {},
header = param.header,
requestUrl;
data._app_id = this.getAppId();
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
});
return;
}
if(res.data.status){
if(res.data.status == 401){
that.login();
return;
}
if(res.data.status != 0){
that.hideToast();
that.showModal({
content: ''+res.data.data
});
return;
}
}
typeof param.success == 'function' && param.success(res.data);
},
fail: function(res){
that.showModal({
content: '请求失败 '+res.errMsg
})
typeof param.fail == 'function' && param.fail(res.data);
},
complete: function(res){
typeof param.complete == 'function' && param.complete(res.data);
}
});
},
turnToPage: function(url, isRedirect){
var tabBarPagePathArr = this.getTabPagePathArr();
// tabBar中的页面改用switchTab跳转
if(tabBarPagePathArr.indexOf(url) != -1) {
this.switchToTab(url);
return;
}
if(!isRedirect){
wx.navigateTo({
url: url
});
} else {
wx.redirectTo({
url: url
});
}
},
switchToTab: function(url){
wx.switchTab({
url: url
});
},
turnBack: function(){
wx.navigateBack();
},
setPageTitle: function(title){
wx.setNavigationBarTitle({
title: title
});
},
showToast: function(param){
wx.showToast({
title: param.title,
icon: param.icon,
duration: param.duration || 1500,
success: function(res){
typeof param.success == 'function' && param.success(res);
},
fail: function(res){
typeof param.fail == 'function' && param.fail(res);
},
complete: function(res){
typeof param.complete == 'function' && param.complete(res);
}
})
},
hideToast: function(){
wx.hideToast();
},
showModal: function(param){
wx.showModal({
title: param.title || '提示',
content: param.content,
showCancel: param.showCancel || false,
cancelText: param.cancelText || '取消',
cancelColor: param.cancelColor || '#000000',
confirmText: param.confirmText || '确定',
confirmColor: param.confirmColor || '#3CC51F',
success: function(res) {
if (res.confirm) {
typeof param.confirm == 'function' && param.confirm(res);
} else {
typeof param.cancel == 'function' && param.cancel(res);
}
},
fail: function(res){
typeof param.fail == 'function' && param.fail(res);
},
complete: function(res){
typeof param.complete == 'function' && param.complete(res);
}
})
},
chooseVideo: function(callback, maxDuration){
wx.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: maxDuration || 60,
camera: ['front', 'back'],
success: function (res) {
typeof callback == 'function' && callback(res.tempFilePaths[0]);
}
})
},
chooseImage: function(callback, count){
var that = this;
wx.chooseImage({
count: count || 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilePaths = res.tempFilePaths,
imageUrls = [];
that.showToast({
title: '提交中...',
icon: 'loading',
duration: 10000
});
for (var i = 0; i < tempFilePaths.length; i++) {
wx.uploadFile({
url : that.globalData.siteBaseUrl+ '/index.php?r=AppData/uploadImg',
filePath: tempFilePaths[i],
name: 'img_data',
success: function(res){
var data = JSON.parse(res.data);
if(data.status == 0){
imageUrls.push(data.data);
if(imageUrls.length == tempFilePaths.length){
that.hideToast();
typeof callback == 'function' && callback(imageUrls);
}
} else {
that.showModal({
content: data.data
})
}
},
fail: function(res){
console.log(res.errMsg);
}
})
}
}
})
},
previewImage: function(previewUrl, previewUrlsArray){
wx.previewImage({
current: previewUrl,
urls: previewUrlsArray
})
},
playVoice: function(filePath){
wx.playVoice({
filePath: filePath
});
},
pauseVoice: function(){
wx.pauseVoice();
},
// 统计用户分享
countUserShareApp: function(){
this.sendRequest({
url: '/index.php?r=AppShop/UserShareApp'
});
},
// 调用微信支付接口
wxPay: function(param){
var _this = this;
wx.requestPayment({
'timeStamp': param.timeStamp,
'nonceStr': param.nonceStr,
'package': param.package,
'signType': 'MD5',
'paySign': param.paySign,
success: function(res){
typeof param.success === 'function' && param.success();
_this.wxPaySuccess(param);
},
fail: function(res){
if(res.errMsg === 'requestPayment:fail cancel'){
return;
}
_this.showModal({
content: res.errMsg
})
_this.wxPayFail(param, res.errMsg);
}
})
},
wxPaySuccess: function(param){
var orderId = param.orderId,
goodsType = param.goodsType,
formId = param.package.substr(10),
t_num = goodsType == 1 ? 'AT0104':'AT0009';
this.sendRequest({
url: '/index.php?r=AppShop/SendXcxOrderCompleteMsg',
data: {
formId: formId,
t_num: t_num,
order_id: orderId
}
})
},
wxPayFail: function(param, errMsg){
var orderId = param.orderId,
formId = param.package.substr(10);
this.sendRequest({
url: '/index.php?r=AppShop/SendXcxOrderCompleteMsg',
data: {
formId: formId,
t_num: 'AT0010',
order_id: orderId,
fail_reason: errMsg
}
})
},
// 拨打电话
makePhoneCall: function(number, callback){
if(number.currentTarget){
var dataset = number.currentTarget.dataset;
number = dataset.number;
}
wx.makePhoneCall({
phoneNumber: number,
success: callback
})
},
// 获取地理位置
getLoca
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序精选源码亲测可用_喜乐茶铺商城小程序.zip
共293个文件
js:72个
wxss:64个
wxml:62个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 112 浏览量
2023-06-29
20:42:56
上传
评论
收藏 752KB ZIP 举报
温馨提示
微信小程序精选源码亲测可用_喜乐茶铺商城小程序.zip
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序精选源码亲测可用_喜乐茶铺商城小程序.zip (293个子文件)
._addAddress 175B
._bindCellphone 175B
._components 175B
._couponDetail 175B
._couponList 175B
._goodsComment 175B
._goodsDetail 175B
._images 175B
._logisticsPage 175B
._makeAppointment 175B
._makeComment 175B
._myAddress 175B
._myIntegral 175B
._myMessage 175B
._myOrder 175B
._orderDetail 175B
._page10000 175B
._page10001 175B
._page10002 175B
._page10004 175B
._page10005 175B
._page10006 175B
._page10007 175B
._page10008 175B
._page10009 175B
._pages 175B
._paySuccess 175B
._previewOrderDetail 175B
._shoppingCart 175B
._toStoreDetail 175B
._userCenter 175B
._utils 175B
._verificationCodePage 175B
._vipCard 175B
._wxParse 175B
6.jpg 35KB
12.jpg 33KB
3.jpg 24KB
2.jpg 22KB
app.js 67KB
page10000.js 39KB
page10009.js 24KB
page10006.js 22KB
page10004.js 22KB
page10007.js 22KB
page10005.js 22KB
page10008.js 22KB
page10001.js 22KB
page10002.js 15KB
orderDetail.js 14KB
previewOrderDetail.js 11KB
toStoreDetail.js 10KB
goodsDetail.js 10KB
myMessage.js 9KB
shoppingCart.js 8KB
wxDiscode.js 7KB
myOrder.js 7KB
html2json.js 6KB
myIntegral.js 6KB
addAddress.js 5KB
bindCellphone.js 5KB
htmlparser.js 5KB
makeAppointment.js 4KB
myAddress.js 4KB
wxParse.js 4KB
makeComment.js 3KB
vipCard.js 3KB
couponDetail.js 3KB
verificationCodePage.js 3KB
userCenter.js 2KB
goodsComment.js 2KB
paySuccess.js 1KB
couponList.js 964B
util.js 917B
logisticsPage.js 370B
._page10006.js 175B
._addAddress.js 175B
._page10000.js 175B
._page10001.js 175B
._page10009.js 175B
._userCenter.js 175B
._myMessage.js 175B
._page10004.js 175B
._verificationCodePage.js 175B
._myOrder.js 175B
._previewOrderDetail.js 175B
._couponDetail.js 175B
._paySuccess.js 175B
._bindCellphone.js 175B
._page10005.js 175B
._goodsComment.js 175B
._myIntegral.js 175B
._goodsDetail.js 175B
._page10008.js 175B
._orderDetail.js 175B
._toStoreDetail.js 175B
._shoppingCart.js 175B
._myAddress.js 175B
._makeComment.js 175B
._makeAppointment.js 175B
共 293 条
- 1
- 2
- 3
资源评论
HappyGirl快乐女孩
- 粉丝: 1w+
- 资源: 4156
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功