Browse Source

更新部分网络请求方法

master
杜叶春 2 years ago
parent
commit
f4e98a3472
  1. 69
      app.js
  2. 5
      app.json
  3. 14
      app.wxss
  4. 116
      pages/address/address.js
  5. 128
      pages/address/index.js
  6. 4
      pages/address/index.wxml
  7. 284
      pages/address/upaddress.js
  8. 0
      pages/address/upaddress.json
  9. 0
      pages/address/upaddress.wxml
  10. 0
      pages/address/upaddress.wxss
  11. 328
      pages/address/upaddress/upaddress.js
  12. 1
      pages/article/article.js
  13. 1
      pages/bangding/bangding.js
  14. 136
      pages/cart/cart.js
  15. 1
      pages/collection/collection.js
  16. 1
      pages/comment/comment.js
  17. 2
      pages/coupon/index.js
  18. 2
      pages/coupon/index.json
  19. 8
      pages/distribution/detail.js
  20. 2
      pages/distribution/detail.json
  21. 1
      pages/distribution/list.js
  22. 1
      pages/distribution/user.js
  23. 1
      pages/envelope/envelope.js
  24. 1
      pages/footprint/footprint.js
  25. 1
      pages/group_buy/cantuan.js
  26. 2
      pages/group_buy/cantuan.json
  27. 1
      pages/group_buy/comment.js
  28. 4
      pages/group_buy/detail.js
  29. 2
      pages/group_buy/detail.json
  30. 1
      pages/group_buy/group.js
  31. 2
      pages/group_buy/group.json
  32. 1
      pages/group_buy/payfor.js
  33. 208
      pages/index/index.js
  34. 5
      pages/index/index.json
  35. 6
      pages/index/index.wxml
  36. 5
      pages/index/index.wxss
  37. 1
      pages/listdetail/listdetail.js
  38. 1
      pages/live/index.js
  39. 78
      pages/login/login.js
  40. 5
      pages/login/login.json
  41. 33
      pages/login/login.wxml
  42. 164
      pages/login/login.wxss
  43. 229
      pages/logins/logins.js
  44. 4
      pages/logins/logins.json
  45. 66
      pages/logins/logins.wx.js
  46. 29
      pages/logins/logins.wxml
  47. 160
      pages/logins/logins.wxss
  48. 1
      pages/logistics/logistics.js
  49. 77
      pages/new/new.js
  50. 3
      pages/notice/index.js
  51. 1
      pages/notice/notice.js
  52. 3
      pages/order/detail.js
  53. 2
      pages/order/order.js
  54. 1
      pages/order/pay.js
  55. 8
      pages/product/detail.js
  56. 2
      pages/product/detail.json
  57. 1
      pages/return_goods/index.js
  58. 1
      pages/return_goods/return_goods.js
  59. 28
      pages/search/search.js
  60. 4
      pages/search/search.wxml
  61. 1
      pages/set/set.js
  62. 1
      pages/share/index.js
  63. 2
      pages/share/index.json
  64. 2
      pages/share/share.js
  65. 1
      pages/sign_in/sign_in.js
  66. 1
      pages/user/recharge.js
  67. 3
      pages/user/score.js
  68. 1
      pages/user/transfer1.js
  69. 1
      pages/user/transfer_jifen.js
  70. 53
      pages/user/user.js
  71. 2
      pages/user/user.json
  72. 8
      pages/user/user.wxml
  73. 2
      pages/user/user.wxss
  74. 1
      pages/user/wallet.js
  75. 1
      pages/user/withdrawals.js
  76. 2
      project.config.json
  77. 5
      project.private.config.json
  78. 16
      request.js
  79. 133
      utils/server.js
  80. 58
      utils/util.js
  81. 6
      wxSearch/wxSearch.wxml

69
app.js

@ -1,4 +1,4 @@
var request = require('request.js'); var WXAPI = require('./utils/server.js');
var util = require('./utils/util.js'); var util = require('./utils/util.js');
App({ App({
d: { d: {
@ -11,17 +11,15 @@ App({
bf_color: '#FF6347', bf_color: '#FF6347',
h_color: '#FF63477', h_color: '#FF63477',
order: {}, order: {},
ceshiUrl: util.getUri(), ceshiUrl: util.getUrl(),
titlee: '', titlee: '',
bgcolor: '', bgcolor: '',
}, },
onLaunch: function (options) { onLaunch: function (options) {
//调用API从本地缓存中获取数据 //调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || [] var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now()) logs.unshift(Date.now())
wx.setStorageSync('logs', logs); wx.setStorageSync('logs', logs);
this.request = request;
}, },
//控制授权登入 //控制授权登入
@ -32,7 +30,7 @@ App({
return true return true
} else { } else {
wx.navigateTo({ wx.navigateTo({
url: 'pages/login/login' // url: 'pages/login/login'
}) })
} }
} else { } else {
@ -84,57 +82,48 @@ App({
// 获取用户会话密钥 // 获取用户会话密钥
getUserSessionKey: function (code, cb, stype, callback) { getUserSessionKey: function (code, cb, stype, callback) {
var that = this; var that = this;
wx.request({ WXAPI.appIndex({
url: that.d.ceshiUrl + '&action=app&m=index',
method: 'post',
data: {
code: code, code: code,
nickName: stype.nickName, nickName: stype.nickName,
avatarUrl: stype.avatarUrl, avatarUrl: stype.avatarUrl,
gender: stype.gender, gender: stype.gender,
referee_openid: this.globalData.userInfo.referee_openid || '' referee_openid: this.globalData.userInfo.referee_openid || ''
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
var data = res.data;
if (data.status == 0) { if (data.status == 0) {
wx.showToast({ wx.showToast({
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
return false; return false;
} }
that.d.ceshiUrl = that.d.ceshiUrl + '&token=' + res.data.access_token; // 线上密钥 that.d.ceshiUrl = that.d.ceshiUrl + '&token=' + data.access_token; // 线上密钥
that.d.localhost = that.d.localhost + '&token=' + res.data.access_token; // 本地密钥 that.d.localhost = that.d.localhost + '&token=' + data.access_token; // 本地密钥
that.globalData.userInfo['plug_ins'] = res.data.plug_ins; // 插件状态 that.globalData.userInfo['plug_ins'] = data.plug_ins; // 插件状态
that.globalData.userInfo['coupon'] = res.data.coupon; // 优惠券状态 that.globalData.userInfo['coupon'] = data.coupon; // 优惠券状态
that.globalData.userInfo['wallet'] = res.data.wallet; // 钱包状态 that.globalData.userInfo['wallet'] = data.wallet; // 钱包状态
that.globalData.userInfo['sign'] = res.data.sign; // 签到状态 that.globalData.userInfo['sign'] = data.sign; // 签到状态
that.globalData.userInfo['sign_status'] = res.data.sign_status; // 是否签名 that.globalData.userInfo['sign_status'] = data.sign_status; // 是否签名
that.globalData.userInfo['sign_image'] = res.data.sign_image; // 签到图片 that.globalData.userInfo['sign_image'] = data.sign_image; // 签到图片
that.globalData.userInfo['user_id'] = res.data.user_id; // user_id that.globalData.userInfo['user_id'] = data.user_id; // user_id
that.globalData.userInfo['nickName'] = res.data.nickName; that.globalData.userInfo['nickName'] = data.nickName;
that.globalData.userInfo['avatarUrl'] = res.data.avatarUrl; //头像 that.globalData.userInfo['avatarUrl'] = data.avatarUrl; //头像
that.globalData.userInfo['session_key'] = res.data.user.session_key; that.globalData.userInfo['session_key'] = data.user.session_key;
that.globalData.userInfo['openid'] = res.data.user.openid; that.globalData.userInfo['openid'] = data.user.openid;
that.globalData.userInfo['nickName'] = res.data.user.nickName; that.globalData.userInfo['nickName'] = data.user.nickName;
that.globalData.userInfo['gender'] = res.data.user.gender; that.globalData.userInfo['gender'] = data.user.gender;
that.globalData.userInfo['company'] = res.data.user.company; that.globalData.userInfo['company'] = data.user.company;
that.globalData.userInfo['bgcolor'] = res.data.user.bgcolor; that.globalData.userInfo['bgcolor'] = data.user.bgcolor;
//修改缓存写入 //修改缓存写入
wx.setStorageSync('userInfo', that.globalData.userInfo); wx.setStorageSync('userInfo', that.globalData.userInfo);
callback() callback()
}, }
fail: function (e) { else {
wx.showToast({ that.showToast(res.err);
title: '网络异常!err:getsessionkeys', }
duration: 2000
});
},
}); });
}, },

5
app.json

@ -18,7 +18,7 @@
"pages/share/share", "pages/share/share",
"pages/address/index", "pages/address/index",
"pages/address/address", "pages/address/address",
"pages/address/upaddress/upaddress", "pages/address/upaddress",
"pages/cart/cart", "pages/cart/cart",
"pages/order/pay", "pages/order/pay",
"pages/order/detail", "pages/order/detail",
@ -42,7 +42,6 @@
"pages/bangding/bangding", "pages/bangding/bangding",
"pages/notice/notice", "pages/notice/notice",
"pages/notice/index", "pages/notice/index",
"pages/logins/logins",
"pages/live/index", "pages/live/index",
"pages/distribution/list", "pages/distribution/list",
"pages/distribution/user", "pages/distribution/user",
@ -51,7 +50,7 @@
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#ffffff", "navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "来客电商", "navigationBarTitleText": "互利商城",
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"enablePullDownRefresh": true "enablePullDownRefresh": true
}, },

14
app.wxss

@ -1,9 +1,11 @@
/**app.wxss**/ /**app.wxss**/
page{ page {
background: #fff; font-family: '微软雅黑' background: #fff; font-family: '微软雅黑';
} height:100%;
width:100%;
}
.container { .container {
height: 100%; height: 100%;
display: flex; display: flex;
@ -171,12 +173,6 @@ color:#FFFFFF;
background-color:#d9002f; background-color:#d9002f;
} }
page{
height:100%;
width:100%;
}
/* /加载页面/ */ /* /加载页面/ */
.body{ .body{
background-color: #f2f2f2; background-color: #f2f2f2;

116
pages/address/address.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
var t = 0; var t = 0;
var moveY = 200; var moveY = 200;
var index = [0, 0, 0]; var index = [0, 0, 0];
@ -62,33 +63,27 @@ Page({
*/ */
AddressManagement: function () { AddressManagement: function () {
var that = this; var that = this;
wx.request({ WXAPI.addressManagement({
url: app.d.ceshiUrl + '&action=user&m=AddressManagement',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
}, }).then(res => {
method: "POST", if (res.status == 1) {
header: { var data = res;
'content-type': 'application/x-www-form-urlencoded' // 默认值 var sheng = data.sheng;
}, var shi = data.shi;
success: function (res) { var xian = data.xian;
if (res.data.status == 1) {
var sheng = res.data.sheng;
var shi = res.data.shi;
var xian = res.data.xian;
that.setData({ that.setData({
sheng: sheng, sheng: sheng,
shi: shi, shi: shi,
xian: xian xian: xian
}); });
} else { }
else {
wx.showToast({ wx.showToast({
title: '非法操作!', title: '非法操作!',
duration: 2000 duration: 2000
}); });
} }
} });
})
}, },
// 点击选择城市 // 点击选择城市
translate: function (e) { translate: function (e) {
@ -139,20 +134,13 @@ Page({
// 根据省获取市 // 根据省获取市
getCityArr: function (count) { getCityArr: function (count) {
var that = this; var that = this;
wx.request({ WXAPI.getCityArr({
url: app.d.ceshiUrl + '&action=user&m=getCityArr',
data: {
count: count, count: count,
}, }).then(res => {
method: "POST", if (res.status == 1) {
header: { var data = res;
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var shi = res.data.shi;
that.setData({ that.setData({
shi: shi shi: data.shi
}); });
} else { } else {
wx.showToast({ wx.showToast({
@ -160,27 +148,19 @@ Page({
duration: 2000 duration: 2000
}); });
} }
} });
})
}, },
// 根据省市获取县 // 根据省市获取县
getCountyInfo: function (count, column) { getCountyInfo: function (count, column) {
var that = this; var that = this;
wx.request({ WXAPI.getCountyInfo({
url: app.d.ceshiUrl + '&action=user&m=getCountyInfo',
data: {
count: count, count: count,
column: column, column: column,
}, }).then(res => {
method: "POST", if (res.status == 1) {
header: { var data = res;
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var xian = res.data.xian;
that.setData({ that.setData({
xian: xian xian: data.xian
}); });
} else { } else {
wx.showToast({ wx.showToast({
@ -188,28 +168,21 @@ Page({
duration: 2000 duration: 2000
}); });
} }
} });
})
}, },
// 滑动事件结束 // 滑动事件结束
Preservation: function (rew) { Preservation: function (rew) {
var that = this; var that = this;
wx.request({ WXAPI.preservation({
url: app.d.ceshiUrl + '&action=user&m=Preservation',
data: {
sheng: rew[0], sheng: rew[0],
shi: rew[1], shi: rew[1],
xuan: rew[2] xuan: rew[2]
}, }).then(res => {
method: "POST", if (res.status == 1) {
header: { var data = res;
'content-type': 'application/x-www-form-urlencoded' // 默认值 var province = data.province;
}, var city = data.city;
success: function (res) { var county = data.county;
if (res.data.status == 1) {
var province = res.data.province;
var city = res.data.city;
var county = res.data.county;
that.setData({ that.setData({
province: province, province: province,
city: city, city: city,
@ -221,8 +194,7 @@ Page({
duration: 2000 duration: 2000
}); });
} }
} });
})
}, },
// 点击保存 // 点击保存
SaveAddress: function (e) { SaveAddress: function (e) {
@ -252,9 +224,7 @@ Page({
mobile = e.detail.value.mobile; mobile = e.detail.value.mobile;
//预处理验证手机号码 //预处理验证手机号码
if (mobile.match(/^\d{11}$/)) { if (mobile.match(/^\d{11}$/)) {
wx.request({ WXAPI.saveAddress({
url: app.d.ceshiUrl + '&action=user&m=SaveAddress',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
user_name: e.detail.value.user_name, user_name: e.detail.value.user_name,
mobile: e.detail.value.mobile, mobile: e.detail.value.mobile,
@ -262,22 +232,18 @@ Page({
city: e.detail.value.city, city: e.detail.value.city,
county: e.detail.value.county, county: e.detail.value.county,
address: e.detail.value.address address: e.detail.value.address
}, }).then(res => {
method: "POST", if (res.status == 1) {
header: { var data = res;
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 0) {
wx.showToast({ wx.showToast({
title: res.data.info, title: data.info,
icon: 'loading', icon: 'loading',
duration: 1500 duration: 1500
}) })
} else { } else {
app.d.islogin = true; app.d.islogin = true;
wx.showToast({ wx.showToast({
title: res.data.info, title: data.info,
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}); });
@ -286,15 +252,7 @@ Page({
delta: 1 delta: 1
}); });
} }
},
fail: function () {
// fail
wx.showToast({
title: '网络异常!',
duration: 2000
}); });
}
})
} else { } else {
wx.showToast({ wx.showToast({
title: '手机号码格式错误,请重新输入!', title: '手机号码格式错误,请重新输入!',

128
pages/address/index.js

@ -1,4 +1,5 @@
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
address: [], address: [],
@ -29,37 +30,26 @@ Page({
content: '你确认移除吗?', content: '你确认移除吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
console.log(11) WXAPI.addressDelselect({
wx.request({
url: app.d.ceshiUrl + '&action=address&m=del_select',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
id_arr: carts id_arr: carts
}, }).then(res => {
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT if (res.status == 1) {
header: {// 设置请求的 header var data = res;
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
// success
var status = res.data.status;
if (status == 1) {
wx.showToast({ wx.showToast({
title: res.data.succ, title: '地址已清空',
duration: 2000 duration: 2000
}); });
that.setData({ that.setData({
flag: false, flag: false,
}); });
that.DataonLoad(); that.DataonLoad();
} else { } else {
wx.showToast({ wx.showToast({
title: res.data.err, title: res.err,
duration: 2000 duration: 2000
}); });
} }
},
}); });
} else { } else {
that.DataonLoad(); that.DataonLoad();
@ -99,19 +89,12 @@ Page({
} else { } else {
var cartId = 0; var cartId = 0;
} }
WXAPI.addressIndex({
wx.request({
url: app.d.ceshiUrl + '&action=address&m=index',
data: {
openid: app.globalData.userInfo.openid openid: app.globalData.userInfo.openid
}, }).then(res => {
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT if (res.status == 1) {
header: {// 设置请求的 header var data = res;
'Content-Type': 'application/x-www-form-urlencoded' var address = data.adds;
},
success: function (res) {
// success
var address = res.data.adds;
if (address == '') { if (address == '') {
var address = [] var address = []
} }
@ -119,14 +102,8 @@ Page({
address: address, address: address,
cartId: cartId, cartId: cartId,
}) })
},
fail: function () {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}) });
}, },
bindCheckbox: function (e) { bindCheckbox: function (e) {
@ -238,20 +215,13 @@ Page({
success: function (t_res) { success: function (t_res) {
console.log(t_res.confirm) console.log(t_res.confirm)
if (t_res.confirm) { if (t_res.confirm) {
wx.request({ WXAPI.addressSetDefault({
url: app.d.ceshiUrl + '&action=address&m=set_default',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
addr_id: addrId addr_id: addrId
}, }).then(res => {
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT if (res.status == 1) {
header: {// 设置请求的 header var data = res;
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var status = res.data.status;
var cartId = that.data.cartId; var cartId = that.data.cartId;
if (status == 1) {
if (cartId != '0' || cartId == 'group') { if (cartId != '0' || cartId == 'group') {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1
@ -259,21 +229,13 @@ Page({
return false; return false;
} }
wx.showToast({ wx.showToast({
title: res.data.err, title: '设置成功',
duration: 2000 duration: 2000
}); });
that.DataonLoad(); that.DataonLoad();
} else { } else {
wx.showToast({ wx.showToast({
title: res.data.err, title: res.err,
duration: 2000
});
}
},
fail: function () {
// fail
wx.showToast({
title: '网络异常!',
duration: 2000 duration: 2000
}); });
} }
@ -292,32 +254,15 @@ Page({
title: '提示', title: '提示',
content: '你确认移除吗', content: '你确认移除吗',
success: function (res) { success: function (res) {
res.confirm && wx.request({ res.confirm && WXAPI.addressDelAdds({
url: app.d.ceshiUrl + '&action=address&m=del_adds',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
id_arr: addrId id_arr: addrId
}, }).then(res => {
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT if (res.status == 1) {
header: {// 设置请求的 header
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
// success
var status = res.data.status;
if (status == 1) {
that.DataonLoad(); that.DataonLoad();
} else { } else {
wx.showToast({ wx.showToast({
title: res.data.err, title: res.err,
duration: 2000
});
}
},
fail: function () {
// fail
wx.showToast({
title: '网络异常!',
duration: 2000 duration: 2000
}); });
} }
@ -330,18 +275,13 @@ Page({
DataonLoad: function () { DataonLoad: function () {
var that = this; var that = this;
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
wx.request({ WXAPI.addressIndex({
url: app.d.ceshiUrl + '&action=address&m=index',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
}, }).then(res => {
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT if (res.status == 1) {
header: {// 设置请求的 header var data = res;
'Content-Type': 'application/x-www-form-urlencoded' var address = data.adds;
}, that.numbers = data.adds;
success: function (res) {
var address = res.data.adds;
that.numbers = res.data.adds;
if (address == '') { if (address == '') {
var address = [] var address = []
} }
@ -349,20 +289,14 @@ Page({
address: address, address: address,
selectedAllStatus: false selectedAllStatus: false
}) })
},
fail: function () {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}) });
}, },
//修改跳转 //修改跳转
upaddress: function (e) { upaddress: function (e) {
var addrId = e.currentTarget.dataset.id var addrId = e.currentTarget.dataset.id
wx.navigateTo({ wx.navigateTo({
url: '../address/upaddress/upaddress?addr_id=' + addrId, url: '../address/upaddress?addr_id=' + addrId,
}) })
}, },
}) })

4
pages/address/index.wxml

@ -12,7 +12,7 @@
<text class="address-phone">{{item.tel}}</text> <text class="address-phone">{{item.tel}}</text>
</view> </view>
<view class="address-info">{{item.address_xq}}</view> <view class="address-info">{{item.address_xq}}</view>
<navigator class='address_img_div' url="../address/upaddress/upaddress?addr_id={{item.id}}"><image src='../../images/x_right.png' class='address_img'></image></navigator> <navigator class='address_img_div' url="../address/upaddress?addr_id={{item.id}}"><image src='../../images/x_right.png' class='address_img'></image></navigator>
</view> </view>
<view class="address-edit"> <view class="address-edit">
@ -39,7 +39,7 @@
<navigator style='display:inline-block;' url="../address/upaddress/upaddress?addr_id={{item.id}}"> <navigator style='display:inline-block;' url="../address/upaddress?addr_id={{item.id}}">
<text style='margin:10px'>编辑</text> <text style='margin:10px'>编辑</text>
</navigator> </navigator>

284
pages/address/upaddress.js

@ -0,0 +1,284 @@
var app = getApp();
var WXAPI = require('../../utils/server.js');
var t = 0;
var show = false;
var moveY = 200;
var index = [0, 0, 0];
var sheng = [];//省
var shi = [];//城市
var xian = [];//区县
Page({
/**
* 页面的初始数据
*/
data: {
sheng: sheng,
shi: shi,
xian: xian,
value: [0, 0, 0],
},
// 下拉刷新
onPullDownRefresh: function () {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.AddressManagement();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarColor({
frontColor: app.d.frontColor,
backgroundColor: app.d.bgcolor, //页面标题为路由参数
animation: {
duration: 400,
timingFunc: 'easeIn'
}
})
this.setData({
bgcolor: app.d.bgcolor,
id_arr: options.addr_id
});
this.AddressManagement();
},
/**
* 修改地址
*/
AddressManagement: function () {
var that = this;
WXAPI.addressUpAddsIndex({
openid: app.globalData.userInfo.openid,
id_arr: that.data.id_arr,
}).then(res => {
if (res.status == 1) {
var data = res;
var address = data.adds;
var province = data.province;
var city = data.city;
var county = data.county;
if (address == '') {
var address = []
}
that.setData({
address: address,
province: province,
city: city,
county: county
})
}
});
},
AddressManagement1: function () {
var that = this;
WXAPI.addressManagement({
openid: app.globalData.userInfo.openid,
}).then(res => {
if (res.status == 1) {
var data = res;
var sheng = data.sheng;
var shi = data.shi;
var xian = data.xian;
that.setData({
sheng: sheng,
shi: shi,
xian: xian
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
});
},
// 点击选择城市
translate: function (e) {
if (t == 0) {
moveY = 0;
show = false;
t = 1;
} else {
moveY = 200;
show = true;
t = 0;
}
animationEvents(this, moveY, show);
this.AddressManagement1();
},
//隐藏弹窗浮层
hiddenFloatView(e) {
moveY = 200;
this.setData({
show: false
});
t = 1;
},
//滑动事件
bindChange: function (e) {
var val = e.detail.value
//判断滑动的是第几个column
//若省份column做了滑动则定位到地级市和区县第一位
if (index[0] != val[0]) {
this.getCityArr(val[0]);//获取地级市数据
this.getCountyInfo(val[0], val[1]);//获取区县数据
} else { //若省份column未做滑动,地级市做了滑动则定位区县第一位
if (index[1] != val[1]) {
this.getCountyInfo(val[0], val[1]);//获取区县数据
}
}
index = val;
this.Preservation(index);
},
// 根据省获取市
getCityArr: function (count) {
var that = this;
WXAPI.getCityArr({
count: count,
}).then(res => {
if (res.status == 1) {
var data = res;
that.setData({
shi: data.shi
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
});
},
// 根据省市获取县
getCountyInfo: function (count, column) {
var that = this;
WXAPI.getCountyInfo({
count: count,
column: column,
}).then(res => {
if (res.status == 1) {
var data = res;
that.setData({
xian: data.xian
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
});
},
// 滑动事件结束
Preservation: function (rew) {
var that = this;
WXAPI.preservation({
sheng: rew[0],
shi: rew[1],
xuan: rew[2]
}).then(res => {
if (res.status == 1) {
var data = res;
var province = data.province;
var city = data.city;
var county = data.county;
that.setData({
province: province,
city: city,
county: county,
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
});
},
// 点击保存
SaveAddress: function (e) {
var that = this;
if (e.detail.value.user_name.length == 0) {
wx.showToast({
title: '联系人不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (e.detail.value.mobile.length == 0) {
wx.showToast({
title: '电话不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (e.detail.value.province.length == 0) {
wx.showToast({
title: '城市不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else {
WXAPI.saveAddress({
openid: app.globalData.userInfo.openid,
user_name: e.detail.value.user_name,
id_arr: that.data.id_arr,
mobile: e.detail.value.mobile,
province: e.detail.value.province,
city: e.detail.value.city,
county: e.detail.value.county,
address: e.detail.value.address
}).then(res => {
if (res.status == 1) {
var data = res;
wx.showModal({
title: '提示',
content: data.info,
success: function (res) {
wx.navigateBack({
delta: 1
})
}
});
} else {
wx.showToast({
title: res.err,
icon: 'loading',
duration: 1500
})
}
});
// WXAPI.addressUpAdds({
// from_id: formId,
// userid: app.globalData.userInfo.openid
// }).then(res => {
// if (res.status == 1) {
// var data = res;
// }
// });
}
}
})
//动画事件
function animationEvents(that, moveY, show) {
that.animation = wx.createAnimation({
transformOrigin: "50% 50%",
duration: 400,
timingFunction: "ease",
delay: 0
})
that.animation.translateY(moveY + 'vh').step()
that.setData({
animation: that.animation.export(),
show: show
})
}

0
pages/address/upaddress/upaddress.json → pages/address/upaddress.json

0
pages/address/upaddress/upaddress.wxml → pages/address/upaddress.wxml

0
pages/address/upaddress/upaddress.wxss → pages/address/upaddress.wxss

328
pages/address/upaddress/upaddress.js

@ -1,328 +0,0 @@
var app = getApp();
var t = 0;
var show = false;
var moveY = 200;
var index = [0, 0, 0];
var sheng = [];//省
var shi = [];//城市
var xian = [];//区县
Page({
/**
* 页面的初始数据
*/
data: {
sheng: sheng,
shi: shi,
xian: xian,
value: [0, 0, 0],
},
// 下拉刷新
onPullDownRefresh: function () {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.AddressManagement();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarColor({
frontColor: app.d.frontColor,
backgroundColor: app.d.bgcolor, //页面标题为路由参数
animation: {
duration: 400,
timingFunc: 'easeIn'
}
})
this.setData({
bgcolor: app.d.bgcolor,
id_arr: options.addr_id
});
this.AddressManagement();
},
/**
* 修改地址
*/
AddressManagement: function () {
var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=address&m=up_addsindex',
data: {
openid: app.globalData.userInfo.openid,
id_arr: that.data.id_arr,
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
// success
var address = res.data.adds;
var province = res.data.province;
var city = res.data.city;
var county = res.data.county;
if (address == '') {
var address = []
}
that.setData({
address: address,
province: province,
city: city,
county: county
})
},
})
},
AddressManagement1: function () {
var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=user&m=AddressManagement',
data: {
openid: app.globalData.userInfo.openid,
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var sheng = res.data.sheng;
var shi = res.data.shi;
var xian = res.data.xian;
that.setData({
sheng: sheng,
shi: shi,
xian: xian
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
}
})
},
// 点击选择城市
translate: function (e) {
if (t == 0) {
moveY = 0;
show = false;
t = 1;
} else {
moveY = 200;
show = true;
t = 0;
}
animationEvents(this, moveY, show);
this.AddressManagement1();
},
//隐藏弹窗浮层
hiddenFloatView(e) {
moveY = 200;
this.setData({
show: false
});
t = 1;
},
//滑动事件
bindChange: function (e) {
var val = e.detail.value
//判断滑动的是第几个column
//若省份column做了滑动则定位到地级市和区县第一位
if (index[0] != val[0]) {
this.getCityArr(val[0]);//获取地级市数据
this.getCountyInfo(val[0], val[1]);//获取区县数据
} else { //若省份column未做滑动,地级市做了滑动则定位区县第一位
if (index[1] != val[1]) {
this.getCountyInfo(val[0], val[1]);//获取区县数据
}
}
index = val;
this.Preservation(index);
},
// 根据省获取市
getCityArr: function (count) {
var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=user&m=getCityArr',
data: {
count: count,
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var shi = res.data.shi;
that.setData({
shi: shi
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
}
})
},
// 根据省市获取县
getCountyInfo: function (count, column) {
var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=user&m=getCountyInfo',
data: {
count: count,
column: column,
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var xian = res.data.xian;
that.setData({
xian: xian
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
}
})
},
// 滑动事件结束
Preservation: function (rew) {
var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=user&m=Preservation',
data: {
sheng: rew[0],
shi: rew[1],
xuan: rew[2]
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 1) {
var province = res.data.province;
var city = res.data.city;
var county = res.data.county;
that.setData({
province: province,
city: city,
county: county,
});
} else {
wx.showToast({
title: '非法操作!',
duration: 2000
});
}
}
})
},
// 点击保存
SaveAddress: function (e) {
var that = this;
if (e.detail.value.user_name.length == 0) {
wx.showToast({
title: '联系人不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (e.detail.value.mobile.length == 0) {
wx.showToast({
title: '电话不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else if (e.detail.value.province.length == 0) {
wx.showToast({
title: '城市不得为空!',
icon: 'loading',
duration: 1500
})
wx.hideToast()
} else {
wx.request({
url: app.d.ceshiUrl + '&action=address&m=up_adds',
data: {
openid: app.globalData.userInfo.openid,
user_name: e.detail.value.user_name,
id_arr: that.data.id_arr,
mobile: e.detail.value.mobile,
province: e.detail.value.province,
city: e.detail.value.city,
county: e.detail.value.county,
address: e.detail.value.address
},
method: "POST",
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success: function (res) {
if (res.data.status == 0) {
wx.showToast({
title: res.data.info,
icon: 'loading',
duration: 1500
})
} else {
wx.showModal({
title: '提示',
content: res.data.info,
success: function (res) {
wx.navigateBack({
delta: 1
})
}
});
}
},
fail: function () {
// fail
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
})
}
}
})
//动画事件
function animationEvents(that, moveY, show) {
that.animation = wx.createAnimation({
transformOrigin: "50% 50%",
duration: 400,
timingFunction: "ease",
delay: 0
})
that.animation.translateY(moveY + 'vh').step()
that.setData({
animation: that.animation.export(),
show: show
})
}

1
pages/article/article.js

@ -1,5 +1,6 @@
// pages/article/article.js // pages/article/article.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
//引入这个插件,使html内容自动转换成wxml内容 //引入这个插件,使html内容自动转换成wxml内容
var WxParse = require('../../wxParse/wxParse.js'); var WxParse = require('../../wxParse/wxParse.js');
Page({ Page({

1
pages/bangding/bangding.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
function getNowFormatDate() { function getNowFormatDate() {
var date = new Date(); var date = new Date();
var seperator1 = "-"; var seperator1 = "-";

136
pages/cart/cart.js

@ -1,5 +1,6 @@
var app = getApp(); var app = getApp();
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
page: 1, page: 1,
@ -40,20 +41,12 @@ Page({
duration: 2000 duration: 2000
}); });
} else { } else {
wx.request({ WXAPI.productUpcart({
url: app.d.ceshiUrl + '&action=product&m=up_cart',
method: 'post',
data: {
user_id: that.data.user_id, user_id: that.data.user_id,
num: num, num: num,
cart_id: cart_id cart_id: cart_id
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var status = res.data.status;
if (status == 1) {
util.getUesrBgplus(that, app, false) util.getUesrBgplus(that, app, false)
// 只有大于一件的时候,才能normal状态,否则disable状态 // 只有大于一件的时候,才能normal状态,否则disable状态
var minusStatus = num <= 1 ? 'disabled' : 'normal'; var minusStatus = num <= 1 ? 'disabled' : 'normal';
@ -69,14 +62,6 @@ Page({
}); });
that.sum(); that.sum();
} }
},
fail: function () {
// fail
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
}); });
} }
}, },
@ -94,18 +79,10 @@ Page({
content: '你确认清空全部吗?', content: '你确认清空全部吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
wx.request({ WXAPI.productDelAllCart({
url: app.d.ceshiUrl + '&action=product&m=delAll_cart',
method: 'post',
data: {
user_id: that.data.user_id, user_id: that.data.user_id,
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var data = res.data;
if (data.status == 1) {
wx.showToast({ wx.showToast({
title: '操作成功!', title: '操作成功!',
duration: 2500 duration: 2500
@ -118,7 +95,6 @@ Page({
duration: 2000 duration: 2000
}); });
} }
},
}); });
} }
}, },
@ -189,21 +165,12 @@ Page({
}); });
return false; return false;
} }
//ajax请求 WXAPI.productToCollection({
wx.request({
url: app.d.ceshiUrl + '&action=product&m=to_Collection',
method: 'post',
data: {
user_id: that.data.user_id, user_id: that.data.user_id,
carts: toastStr, carts: toastStr,
}, }).then(res => {
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
util.getUesrBgplus(that, app, false) util.getUesrBgplus(that, app, false)
var data = res.data; if (res.status == 1) {
if (data.status == 1) {
wx.showToast({ wx.showToast({
title: '操作成功!', title: '操作成功!',
duration: 2000 duration: 2000
@ -215,7 +182,6 @@ Page({
duration: 2000 duration: 2000
}); });
} }
},
}); });
}, },
@ -229,20 +195,12 @@ Page({
var cart_id = e.currentTarget.dataset.cartid; var cart_id = e.currentTarget.dataset.cartid;
console.log(pnum) console.log(pnum)
if (pnum > num) { if (pnum > num) {
wx.request({ WXAPI.productUpcart({
url: app.d.ceshiUrl + '&action=product&m=up_cart',
method: 'post',
data: {
user_id: that.data.user_id, user_id: that.data.user_id,
num: num, num: num,
cart_id: cart_id cart_id: cart_id
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var status = res.data.status;
if (status == 1) {
util.getUesrBgplus(that, app, false) util.getUesrBgplus(that, app, false)
// 只有大于一件的时候,才能normal状态,否则disable状态 // 只有大于一件的时候,才能normal状态,否则disable状态
var minusStatus = num <= 1 ? 'disabled' : 'normal'; var minusStatus = num <= 1 ? 'disabled' : 'normal';
@ -258,13 +216,6 @@ Page({
}); });
that.sum(); that.sum();
} }
},
fail: function () {
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
}); });
} else { } else {
wx.showToast({ wx.showToast({
@ -401,30 +352,19 @@ Page({
title: '提示', title: '提示',
content: '你确认移除吗', content: '你确认移除吗',
success: function (res) { success: function (res) {
res.confirm && WXAPI.productDelcart({
res.confirm && wx.request({
url: app.d.ceshiUrl + '&action=product&m=delcart',
method: 'post',
data: {
carts: carts, carts: carts,
}, }).then(res => {
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
util.getUesrBgplus(that, app, false) util.getUesrBgplus(that, app, false)
//--init data if (res.status == 1) {
var data = res.data;
if (data.status == 1) {
that.loadProductData(); that.loadProductData();
}
} else { else {
wx.showToast({ wx.showToast({
title: '操作失败!', title: '操作失败!',
duration: 2000 duration: 2000
}); });
} }
},
}); });
}, },
fail: function () { fail: function () {
@ -440,24 +380,19 @@ Page({
// 数据加载 // 数据加载
loadProductData: function () { loadProductData: function () {
var that = this; var that = this;
wx.request({
url: app.d.ceshiUrl + '&action=product&m=Shopping', WXAPI.productShopping({
method: 'post',
data: {
user_id: app.globalData.userInfo.openid user_id: app.globalData.userInfo.openid
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
var cart = res.data.cart;
that.setData({ that.setData({
carts: cart, carts: data.cart,
selectedAllStatus: false, selectedAllStatus: false,
total: '¥0.00', total: '¥0.00',
remind: '' remind: ''
}); });
}, }
}); });
}, },
bindManual: function (e) { bindManual: function (e) {
@ -472,20 +407,12 @@ Page({
console.log(num, cat_num, pnum) console.log(num, cat_num, pnum)
if (Number(num) > 0) { if (Number(num) > 0) {
if (Number(num) <= Number(pnum)) { if (Number(num) <= Number(pnum)) {
wx.request({ WXAPI.productUpcart({
url: app.d.ceshiUrl + '&action=product&m=up_cart',
method: 'post',
data: {
user_id: that.data.user_id, user_id: that.data.user_id,
num: num, num: num,
cart_id: carid cart_id: carid
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var status = res.data.status;
if (status == 1) {
// 只有大于一件的时候,才能normal状态,否则disable状态 // 只有大于一件的时候,才能normal状态,否则disable状态
var minusStatus = num <= 1 ? 'disabled' : 'normal'; var minusStatus = num <= 1 ? 'disabled' : 'normal';
// 购物车数据 // 购物车数据
@ -500,13 +427,6 @@ Page({
}); });
that.sum(); that.sum();
} }
},
fail: function () {
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
}); });
} else { } else {
wx.showToast({ wx.showToast({

1
pages/collection/collection.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
remind: '加载中', remind: '加载中',

1
pages/comment/comment.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
var that; var that;
Page({ Page({
data: { data: {

2
pages/coupon/index.js

@ -1,6 +1,6 @@
//获取应用实例 //获取应用实例
var app = getApp(); var app = getApp();
var common = require("../../utils/common.js"); var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
currentTab: 0, currentTab: 0,

2
pages/coupon/index.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "优惠券", "navigationBarTitleText": "优惠券",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

8
pages/distribution/detail.js

@ -1,7 +1,7 @@
//获取应用实例 //获取应用实例
var app = getApp(); var app = getApp();
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
var WXAPI = require('../../utils/server.js');
//引入这个插件,使html内容自动转换成wxml内容 //引入这个插件,使html内容自动转换成wxml内容
var WxParse = require('../../wxParse/wxParse.js'); var WxParse = require('../../wxParse/wxParse.js');
Page({ Page({
@ -579,7 +579,7 @@ Page({
} else { } else {
wx.showToast({ wx.showToast({
icon: 'loading', icon: 'loading',
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
} }
@ -696,7 +696,7 @@ Page({
that.data.itemData.isCollect = false; that.data.itemData.isCollect = false;
} else { } else {
wx.showToast({ wx.showToast({
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
that.setData({ that.setData({
@ -740,7 +740,7 @@ Page({
}) })
} else { } else {
wx.showToast({ wx.showToast({
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
that.setData({ that.setData({

2
pages/distribution/detail.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "商品详情", "navigationBarTitleText": "商品详情",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

1
pages/distribution/list.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
current: 0, current: 0,

1
pages/distribution/user.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
winWidth: 0, winWidth: 0,

1
pages/envelope/envelope.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
//引入这个插件,使html内容自动转换成wxml内容 //引入这个插件,使html内容自动转换成wxml内容
var WxParse = require('../../wxParse/wxParse.js'); var WxParse = require('../../wxParse/wxParse.js');
Page({ Page({

1
pages/footprint/footprint.js

@ -1,4 +1,5 @@
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
remind: '加载中', remind: '加载中',

1
pages/group_buy/cantuan.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
pop: null, pop: null,

2
pages/group_buy/cantuan.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "我的团", "navigationBarTitleText": "我的团",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

1
pages/group_buy/comment.js

@ -1,5 +1,6 @@
// pages/group_buy/comment.js // pages/group_buy/comment.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**

4
pages/group_buy/detail.js

@ -1,5 +1,7 @@
var WxParse = require('../../wxParse/wxParse.js');
var app = getApp(); var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
scrollTop: 0, scrollTop: 0,

2
pages/group_buy/detail.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "商品详情", "navigationBarTitleText": "商品详情",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

1
pages/group_buy/group.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
pop: null, pop: null,

2
pages/group_buy/group.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "爱拼才会赢", "navigationBarTitleText": "爱拼才会赢",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

1
pages/group_buy/payfor.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
function initSubMenuDisplay() { function initSubMenuDisplay() {
return ['hidden', 'hidden', 'hidden']; return ['hidden', 'hidden', 'hidden'];

208
pages/index/index.js

@ -1,6 +1,8 @@
// pages/index/index.js
var app = getApp(); var app = getApp();
var zi = 0; var zi = 0;
var cont_time = 0; //首页tab点击 var cont_time = 0; //首页tab点击
var WXAPI = require('../../utils/server.js');
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
Page({ Page({
data: { data: {
@ -57,7 +59,7 @@ Page({
images: image images: image
}) })
}, },
getMore: function (e) { getMore: function (_e) {
var that = this; var that = this;
var page = that.data.page; var page = that.data.page;
var index = that.data.tabid; var index = that.data.tabid;
@ -65,25 +67,19 @@ Page({
that.setData({ that.setData({
page: page + 1 page: page + 1
}); });
wx.request({ WXAPI.indexGetMore({
url: app.d.ceshiUrl + '&action=Index&m=get_more',
method: 'post',
data: {
page: page, page: page,
index: index, index: index,
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
var prolist = res.data.prolist;
wx.hideNavigationBarLoading() //完成停止加载 wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新 wx.stopPullDownRefresh() //停止下拉刷新
that.setData({ that.setData({
loading: false, loading: false,
}); });
if (prolist == '' || res.data.status == 0) { if (data.prolist == '' || data.status == 0) {
return false; return false;
} else { } else {
var twoList = that.data.twoList; var twoList = that.data.twoList;
@ -94,14 +90,8 @@ Page({
indexTwoData: indexTwoData indexTwoData: indexTwoData
}); });
} }
},
fail: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}) });
}, },
inputConfirm: function (e) { inputConfirm: function (e) {
var that = this, var that = this,
@ -145,17 +135,12 @@ Page({
} }
if (formId != 'the formId is a mock one') { if (formId != 'the formId is a mock one') {
var page = 'pages/index/index' var page = 'pages/index/index'
app.request.wxRequest({ WXAPI.productSaveFormid({
url: '&action=product&m=save_formid',
data: {
from_id: formId, from_id: formId,
userid: app.globalData.userInfo.openid userid: app.globalData.userInfo.openid
}, }).then(res => {
method: 'post',
success: function (res) {
} });
})
} }
}, },
search: function () { search: function () {
@ -174,32 +159,29 @@ Page({
if (userinfo.nickName) { if (userinfo.nickName) {
app.globalData.userInfo = userinfo; app.globalData.userInfo = userinfo;
} }
var openid = app.globalData.userInfo.openid ? app.globalData.userInfo.openid : false; var openid = app.globalData.userInfo.openid ? app.globalData.userInfo.openid : false;
var user_id = '';
if (openid) { if (openid) {
wx.request({ user_id = app.globalData.userInfo.user_id;
url: app.d.ceshiUrl + '&action=Index&m=index', }
method: 'post', WXAPI.homeIndex({
data: { user_id: user_id
user_id: app.globalData.userInfo.user_id }).then(res => {
}, // if (res.status == 1) {
header: { var data = res;
'Content-Type': 'application/x-www-form-urlencoded' var banner = data.banner; // 轮播图
}, var twoList = data.twoList; //产品显示
success: function (res) { var bgcolor = data.bgcolor; //产品显示
var banner = res.data.banner; // 轮播图 var plug = data.plug;
var twoList = res.data.twoList; //产品显示 var title = data.title;
var bgcolor = res.data.bgcolor; //产品显示
var plug = res.data.plug;
var title = res.data.title;
app.d.bgcolor = bgcolor; app.d.bgcolor = bgcolor;
var arr = Object.keys(twoList[0].distributor); var arr = Object.keys(twoList[0].distributor);
var banner_num = Object.keys(banner); // 轮播图 var banner_num = Object.keys(banner); // 轮播图
var notice = res.data.notice; var notice = data.notice;
var indexTwoData = twoList[0].twodata // 获取首页的数据对象 var indexTwoData = twoList[0].twodata // 获取首页的数据对象
app.globalData.logoimg = res.data.logo app.globalData.logoimg = data.logo
app.globalData.title = res.data.title app.globalData.title = data.title
that.setData({ that.setData({
distributor: arr, distributor: arr,
inforList: notice, inforList: notice,
@ -210,9 +192,9 @@ Page({
bgcolor: bgcolor, bgcolor: bgcolor,
plug: plug, plug: plug,
mch_name: title, mch_name: title,
logo: res.data.logo, logo: data.logo,
djname: res.data.djname, djname: data.djname,
zjList: res.data.list zjList: data.list
}); });
wx.setNavigationBarColor({ wx.setNavigationBarColor({
@ -224,79 +206,16 @@ Page({
success: function () { }, success: function () { },
}); });
that.setData({ remind: '' }); that.setData({ remind: '' });
console.log(res.data.list.length) console.log(data.list.length)
if (res.data.list.length) { if (data.list.length) {
that.listnsg(); that.listnsg();
} }
// }
}, // else {
fail: function (e) { // that.showToast(data.err);
wx.showToast({ // }
title: '网络异常!',
duration: 2000
}); });
}, },
})
} else {
wx.request({
url: app.d.ceshiUrl + '&action=Index&m=index',
method: 'post',
data: {},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var banner = res.data.banner; // 轮播图
var twoList = res.data.twoList; //产品显示
var bgcolor = res.data.bgcolor; //产品显示
var plug = res.data.plug; //抽奖产品
var title = res.data.title;
app.d.bgcolor = bgcolor;
var arr = []; //Object.keys(twoList[0].distributor);
var banner_num = Object.keys(banner); // 轮播图
var notice = res.data.notice;
var indexTwoData = twoList[0].twodata // 获取首页的数据对象
app.globalData.logoimg = res.data.logo
app.globalData.title = res.data.title
that.setData({
distributor: arr,
inforList: notice,
banner: banner,
banner_num: banner_num,
twoList: twoList,
indexTwoData: indexTwoData,
bgcolor: bgcolor,
plug: plug,
mch_name: title,
logo: res.data.logo,
djname: res.data.djname,
zjList: res.data.list
});
wx.setNavigationBarColor({
frontColor: app.d.frontColor,
backgroundColor: app.d.bgcolor //页面标题为路由参数
});
wx.setNavigationBarTitle({
title: title,
success: function () { },
});
that.setData({ remind: '' });
if (res.data.list.length) {
that.listnsg();
}
},
fail: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
},
})
}
},
onHide: function () { onHide: function () {
clearTimeout(); clearTimeout();
}, },
@ -374,7 +293,7 @@ Page({
}); });
}, },
//设置点击tab大于第七个是自动跳到后面 //设置点击tab大于第七个是自动跳到后面
checkCor: function (e) { checkCor: function (_e) {
if (this.data.current > 4) { if (this.data.current > 4) {
this.setData({ this.setData({
scrollLeft: 800 scrollLeft: 800
@ -412,10 +331,9 @@ Page({
onReady: function () { onReady: function () {
this.pop = this.selectComponent("#pop") this.pop = this.selectComponent("#pop")
}, },
onLoad: function (e) { onLoad: function (_e) {
var that = this; var that = this;
that.loadProductDetail(); that.loadProductDetail();
}, },
preventTouchMove: function () { preventTouchMove: function () {
@ -432,35 +350,7 @@ Page({
url: '../sign_in/sign_in', url: '../sign_in/sign_in',
}) })
}, },
material: function (res) {
wx.getUserInfo({
success: function (res) {
var userInfo = res.userInfo;
var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女
wx.request({
url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post',
data: {
openid: app.globalData.userInfo.openid,
nickName: nickName,
avatarUrl: avatarUrl,
gender: gender
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
wx.showToast({
title: res.data.info,
success: 2000
});
}
})
}
})
},
//获取用户信息新接口 //获取用户信息新接口
agreeGetUser: function (e) { agreeGetUser: function (e) {
let that = this let that = this
@ -550,26 +440,20 @@ Page({
var nickName = userInfo.nickName; var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl; var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女 var gender = userInfo.gender; //性别 0:未知、1:男、2:女
wx.request({ WXAPI.userMaterial({
url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
nickName: nickName, nickName: nickName,
avatarUrl: avatarUrl, avatarUrl: avatarUrl,
gender: gender gender: gender
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
wx.showToast({ wx.showToast({
title: '授权成功!', title: '授权成功!',
success: 2000 success: 2000
}); });
that.onLoad(); that.onLoad();
} }
}) });
}, },
getqx(event) { getqx(event) {
let name = event.currentTarget.dataset.name let name = event.currentTarget.dataset.name
@ -599,10 +483,10 @@ Page({
title: title, title: title,
imageUrl: that.data.logo, imageUrl: that.data.logo,
path: 'pages/index/index?userid=' + user_id, path: 'pages/index/index?userid=' + user_id,
success: function (res) { success: function (_res) {
console.log('转发成功'); console.log('转发成功');
}, },
fail: function (res) { fail: function (_res) {
console.log('转发失败') console.log('转发失败')
} }
} }

5
pages/index/index.json

@ -1,5 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} },
"navigationBarTitleText": "互利商城"
} }

6
pages/index/index.wxml

@ -47,7 +47,7 @@
<view class='tab'> <view class='tab'>
<scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}"> <scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}">
<view class='tablist'> <view class='tablist'>
<view wx:for="{{twoList}}" wx:key="{{item.id}}" scroll-x class='item {{current==index?"select":""}}' data-pos='{{index}}' data-tabid='{{item.id}}' bindtap='tabItemClick'> <view wx:for="{{twoList}}" wx:key="id" scroll-x class='item {{current==index?"select":""}}' data-pos='{{index}}' data-tabid='{{item.id}}' bindtap='tabItemClick'>
<text class='tab-text'>{{item.name}}</text> <text class='tab-text'>{{item.name}}</text>
</view> </view>
</view> </view>
@ -57,12 +57,12 @@
</view> </view>
</view> </view>
<swiper class='out' current='{{current}}' autoplay="{{false}}" bindchange="contentChange"> <swiper class='out' current='{{current}}' autoplay="{{false}}" bindchange="contentChange">
<swiper-item wx:for="{{twoList}}" wx:for-item="item" wx:key="{{item.id}}"> <swiper-item wx:for="{{twoList}}" wx:for-item="item" wx:key="id">
<scroll-view scroll-y="true" bindscrolltolower="obm"> <scroll-view scroll-y="true" bindscrolltolower="obm">
<!-- /首页轮播图/ --> <!-- /首页轮播图/ -->
<swiper class="swiper-box" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" wx:if="{{item.id == 0 && banner.length >0}}"> <swiper class="swiper-box" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" wx:if="{{item.id == 0 && banner.length >0}}">
<block wx:for="{{banner}}" wx:key="{{item.id}}"> <block wx:for="{{banner}}" wx:key="id">
<navigator url='{{item.url}}'> <navigator url='{{item.url}}'>
<swiper-item> <swiper-item>
<image src="{{item.image}}" id="{{item.id}}" class="slide-image" width="100%" height="200" /> <image src="{{item.image}}" id="{{item.id}}" class="slide-image" width="100%" height="200" />

5
pages/index/index.wxss

@ -644,11 +644,6 @@ button{
box-shadow: 3px 3px 3px #ccc; box-shadow: 3px 3px 3px #ccc;
} }
.title-bar { position: relative; border-bottom: 1rpx solid #eee; height: 100rpx;margin-bottom:10px; } .title-bar { position: relative; border-bottom: 1rpx solid #eee; height: 100rpx;margin-bottom:10px; }
.title-bar wx-image { width: 38rpx; height: 38rpx; } .title-bar wx-image { width: 38rpx; height: 38rpx; }
.title-bar .title { margin: 0 40rpx; } .title-bar .title { margin: 0 40rpx; }

1
pages/listdetail/listdetail.js

@ -1,4 +1,5 @@
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
current: 0, current: 0,

1
pages/live/index.js

@ -1,5 +1,6 @@
// pages/live/index.js // pages/live/index.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**

78
pages/login/login.js

@ -1,21 +1,59 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: {},
onLoad: function(e) {
data: {
click: false, //是否显示弹窗内容
option: false, //显示弹窗或关闭弹窗的操作动画
logoimg: '',
loadtitle:'',
thvm:{}
}, },
onReady: function() { myCatchTouch: function () {
return;
}, },
onShow: function() { // 用户点击显示弹窗
setCloses:function(){
wx.showToast({
title: '没有授权,不能进入小程序个人中心!',
icon: 'none',
duration: 2000
})
this.clickPup()
}, },
onHide: function() { clickPup: function (vm) {
this.setData({
logoimg: app.globalData.logoimg,
loadtitle: app.globalData.title,
thvm: vm ? vm:''
})
let _that = this;
if (!_that.data.click) {
_that.setData({
click: true,
})
}
if (_that.data.option) {
_that.setData({
option: false,
})
// 关闭显示弹窗动画的内容,不设置的话会出现:点击任何地方都会出现弹窗,就不是指定位置点击出现弹窗了
setTimeout(() => {
_that.setData({
click: false,
})
}, 500)
},
onUnload: function() {
} else {
_that.setData({
option: true
})
}
}, },
getUserInfo: function (t) { getUserInfo: function (t) {
wx.showLoading({ wx.showLoading({
title: "正在登录", title: "正在登录",
@ -29,7 +67,6 @@ Page({
var nickName = userInfo.nickName; var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl; var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女 var gender = userInfo.gender; //性别 0:未知、1:男、2:女
// console.log(res.userInfo)
wx.request({ wx.request({
url: app.d.ceshiUrl + '&action=user&m=material', url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post', method: 'post',
@ -59,7 +96,7 @@ Page({
title: '正在登入', title: '正在登入',
success: 2000 success: 2000
}); });
// console.log(e.detail.userInfo) console.log(e.detail.userInfo)
if (e.detail.errMsg == 'getUserInfo:ok') { if (e.detail.errMsg == 'getUserInfo:ok') {
//获取成功设置状态 //获取成功设置状态
app.globalData.userlogin = true; app.globalData.userlogin = true;
@ -78,6 +115,7 @@ Page({
that.setData({ that.setData({
userlogin: false userlogin: false
}) })
that.getOP(e.detail.userInfo) that.getOP(e.detail.userInfo)
} else { } else {
wx.showToast({ wx.showToast({
@ -143,16 +181,21 @@ Page({
getOP: function (res) { getOP: function (res) {
//提交用户信息 获取用户id //提交用户信息 获取用户id
let that = this let that = this
let thatplus = this.data.thvm
app.getUserInfo('', '', res, function (){
let userInfo = res; let userInfo = res;
var user = app.globalData.userInfo; var user = app.globalData.userInfo;
app.globalData.userInfo['avatarUrl'] = userInfo.avatarUrl; // 头像 app.globalData.userInfo['avatarUrl'] = userInfo.avatarUrl; // 头像
app.globalData.userInfo['nickName'] = userInfo.nickName; // 昵称 app.globalData.userInfo['nickName'] = userInfo.nickName; // 昵称
app.globalData.userInfo['gender'] = userInfo.gender; // 性别 app.globalData.userInfo['gender'] = userInfo.gender; // 性别
wx.setStorageSync('userInfo', app.globalData.userInfo); wx.setStorageSync('userInfo', app.globalData.userInfo);
//写入缓存 //写入缓存
var nickName = userInfo.nickName; var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl; var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女 var gender = userInfo.gender; //性别 0:未知、1:男、2:女
wx.request({ wx.request({
url: app.d.ceshiUrl + '&action=user&m=material', url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post', method: 'post',
@ -170,15 +213,18 @@ Page({
title: '授权成功!', title: '授权成功!',
success: 2000 success: 2000
}); });
setTimeout(function () { setTimeout(function () {
wx.navigateBack({ that.clickPup()
delta: 1 thatplus.onLoad()
})
}, 1800); }, 1800);
} }
}) })
}
})
});
}
})

5
pages/login/login.json

@ -1 +1,4 @@
{"navigationBarTitleText":"授权登录"} {
"usingComponents": {},
"component": true
}

33
pages/login/login.wxml

@ -1,13 +1,28 @@
<include src="/commons/extension/extension" /> <!-- 底部弹窗动画的内容 -->
<include src="/commons/navbar/navbar" />
<view class="after-navber"> <view class='pupContent {{click? "showContent": "hideContent"}} {{option? "open": "closes"}}' hover-stop-propagation='true'>
<view style="padding: 0 60rpx"> <image src="../../images/logonsgb.png" catchtap="setCloses"></image>
<view style="padding:80rpx 0 48rpx;border-bottom: 1rpx solid #e3e3e3;margin-bottom: 72rpx;text-align: center"> <view class="pupContent-body">
<image src="/images/icon-wechatapp.png" style="width: 200rpx;height: 200rpx;"></image> <view class="pupContent-head">
<image src="{{ logoimg }}"></image>
<view>欢迎来到{{ loadtitle }}</view>
</view> </view>
<view style="font-size: 13pt;margin-bottom: 40rpx">申请获取以下权限</view>
<view style="color: #888;margin-bottom: 88rpx">获得你的公开信息(昵称、头像等)</view>
<button bindgetuserinfo="" class="login-btn" openType="getUserInfo">授权登录</button></view> <view class="pupContent-title">
为提供更优质的服务,需要获取以下信息:
</view>
<view class="pupContent-con">
<view>· 你的公开信息(昵称、头像等)</view>
</view>
<view>
<button class="pupContent-btn" bindgetuserinfo="agreeGetUser" class="login-btn" openType="getUserInfo" style="background-color: #1AAD19; border-radius:10rpx;height:46px;display:flex;justify-content:center;align-items: center;" >确定</button>
</view>
</view>
</view>
<!-- 固定的背景 -->
<view class='pupContentBG {{click?"showBG":"hideBG"}} {{option?"openBG":"closeBG"}}' catchtap='clickPup' catchtouchmove="myCatchTouch">
</view> </view>

164
pages/login/login.wxss

@ -1,4 +1,160 @@
body{ background: #fff; } .pupContentBG {
.login-btn{ border: none; height: 88rpx; line-height: 88rpx; background: #04be01; color: #fff; font-size: 11pt; border-radius: 999rpx; } width: 100vw !important;
.login-btn::after{ display: none; } height: 100vh !important;
.login-btn.button-hover { box-shadow: inset 0 5rpx 30rpx rgba(0,0,0,.15); } position: fixed !important;
top: 0 !important;
}
.pupContent {
width: 100% !important;
background: #FFFFFF !important;
position: fixed !important;
bottom: 0 !important;
z-index: 999 !important;
border-radius: 16rpx 16rpx 0rpx 0rpx !important;
}
.pupContent >image {
width: 28rpx !important;
height: 28rpx !important;
float: right !important;
margin-right: 30rpx !important;
margin-top: 30rpx !important;
}
.pupContent-body {
margin: 60rpx 40rpx !important;
}
/* 设置显示的背景 */
.pupContent-head {
display: flex !important;
align-items: center !important;
color: #020202 !important;
font-weight:bold !important;
font-size:34rpx !important;
padding-bottom: 60rpx !important;
}
.pupContent-head view{
padding-left: 20rpx !important;
}
.pupContent-head image{
width: 80rpx !important;
height: 80rpx !important;
}
.showBG {
display: block !important;
}
.pupContent-title {
color: #020202 !important;
font-size: 30rpx !important;
font-weight:500 !important;
padding-bottom: 40rpx !important;
}
.pupContent-title {
color: #020202 !important;
font-size:30rpx !important;
}
.pupContent-btn {
height: 90rpx !important;
background-color: #1AAD19 !important;
color: #FFFFFF !important;
font-size:30rpx !important;
font-weight:500 !important;
display: flex !important;
justify-content: center !important;
align-items: center !important;
border-radius:10rpx !important;
}
.pupContent-con {
color: #666666 !important;
font-size:26rpx !important;
padding-bottom: 68rpx !important;
}
.hideBG {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideBGtUp {
from {
background: transparent;
}
to {
background: rgba(0, 0, 0, 0.1);
}
}
@keyframes slideBGDown {
from {
background: rgba(0, 0, 0, 0.1);
}
to {
background: transparent;
}
}
/* 显示或关闭内容时动画 */
.openBG {
animation: slideBGtUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.closeBG {
animation: slideBGDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
/* 设置显示内容 */
.showContent {
display: block;
}
.hideContent {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideContentUp {
from {
height: 0;
}
to {
height: 520rpx;
}
}
@keyframes slideContentDown {
from {
height: 520rpx;
}
to {
height: 0;
}
}
/* 显示或关闭内容时动画 */
.open {
animation: slideContentUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.closes {
animation: slideContentDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}

229
pages/logins/logins.js

@ -1,229 +0,0 @@
var app = getApp();
Page({
data: {
click: false, //是否显示弹窗内容
option: false, //显示弹窗或关闭弹窗的操作动画
logoimg: '',
loadtitle:'',
thvm:{}
},
myCatchTouch: function () {
return;
},
// 用户点击显示弹窗
setCloses:function(){
wx.showToast({
title: '没有授权,不能进入小程序个人中心!',
icon: 'none',
duration: 2000
})
this.clickPup()
},
clickPup: function (vm) {
this.setData({
logoimg: app.globalData.logoimg,
loadtitle: app.globalData.title,
thvm: vm ? vm:''
})
let _that = this;
if (!_that.data.click) {
_that.setData({
click: true,
})
}
if (_that.data.option) {
_that.setData({
option: false,
})
// 关闭显示弹窗动画的内容,不设置的话会出现:点击任何地方都会出现弹窗,就不是指定位置点击出现弹窗了
setTimeout(() => {
_that.setData({
click: false,
})
}, 500)
} else {
_that.setData({
option: true
})
}
},
getUserInfo: function (t) {
wx.showLoading({
title: "正在登录",
mask: !0
})
},
material: function (res) {
wx.getUserInfo({
success: function (res) {
var userInfo = res.userInfo;
var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女
wx.request({
url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post',
data: {
openid: app.globalData.userInfo.openid,
nickName: nickName,
avatarUrl: avatarUrl,
gender: gender
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
wx.showToast({
title: res.data.info,
success: 2000
});
}
})
}
})
},
//获取用户信息新接口
agreeGetUser: function (e) {
let that = this;
wx.showLoading({
title: '正在登入',
success: 2000
});
console.log(e.detail.userInfo)
if (e.detail.errMsg == 'getUserInfo:ok') {
//获取成功设置状态
app.globalData.userlogin = true;
wx.setStorageSync('userlogin', true);
//设置用户信息本地存储
try {
wx.setStorageSync('userInfo', e.detail.userInfo);
} catch (e) {
wx.showToast({
title: '系统提示:网络错误!',
icon: 'warn',
duration: 1500,
})
}
that.setData({
userlogin: false
})
that.getOP(e.detail.userInfo)
} else {
wx.showToast({
title: '没有授权,不能执行该操作!',
icon: 'none',
duration: 2000
})
//没有授权需要弹框
that.setData({
userlogin: true
});
}
},
login: function () {
var that = this;
//取出本地存储用户信息,解决需要每次进入小程序弹框获取用户信息
var userInfo = wx.getStorageSync('userInfo');
wx.login({
success: res => {
app.globalData.code = res.code
wx.setStorageSync('code', res.code)
},
fail: function () {
wx.showToast({
title: '系统提示:网络错误!',
icon: 'warn',
duration: 1500,
})
}
})
wx.getSetting({
success: (res) => {
//没有授权需要弹框
if (!res.authSetting['scope.userInfo']) {
that.setData({
userlogin: true
});
} else {
//判断用户已经授权。不需要弹框
if (app.globalData.userlogin) {
that.setData({
userlogin: false
})
app.globalData.userlogin = true;
wx.setStorageSync('userlogin', true);
} else {
that.setData({
userlogin: true
});
}
}
},
fail: function () {
wx.showToast({
title: '系统提示:网络错误!',
icon: 'warn',
duration: 1500,
})
}
})
},
getOP: function (res) {
//提交用户信息 获取用户id
let that = this
let thatplus = this.data.thvm
app.getUserInfo('', '', res, function (){
let userInfo = res;
var user = app.globalData.userInfo;
app.globalData.userInfo['avatarUrl'] = userInfo.avatarUrl; // 头像
app.globalData.userInfo['nickName'] = userInfo.nickName; // 昵称
app.globalData.userInfo['gender'] = userInfo.gender; // 性别
wx.setStorageSync('userInfo', app.globalData.userInfo);
//写入缓存
var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女
wx.request({
url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post',
data: {
openid: app.globalData.userInfo.openid,
nickName: nickName,
avatarUrl: avatarUrl,
gender: gender
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
wx.showToast({
title: '授权成功!',
success: 2000
});
setTimeout(function () {
that.clickPup()
thatplus.onLoad()
}, 1800);
}
})
})
}
})

4
pages/logins/logins.json

@ -1,4 +0,0 @@
{
"usingComponents": {},
"component": true
}

66
pages/logins/logins.wx.js

@ -1,66 +0,0 @@
// pages/logins/logins.wx.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

29
pages/logins/logins.wxml

@ -1,29 +0,0 @@
<!-- 底部弹窗动画的内容 -->
<!-- <include src="/commons/extension/extension" />
<include src="/commons/navbar/navbar" /> -->
<view class='pupContent {{click? "showContent": "hideContent"}} {{option? "open": "closes"}}' hover-stop-propagation='true'>
<image src="../../images/logonsgb.png" catchtap="setCloses"></image>
<view class="pupContent-body">
<view class="pupContent-head">
<image src="{{ logoimg }}"></image>
<view>欢迎来到{{ loadtitle }}</view>
</view>
<view class="pupContent-title">
为提供更优质的服务,需要获取以下信息:
</view>
<view class="pupContent-con">
<view>· 你的公开信息(昵称、头像等)</view>
</view>
<view>
<button class="pupContent-btn" bindgetuserinfo="agreeGetUser" class="login-btn" openType="getUserInfo" style="background-color: #1AAD19; border-radius:10rpx;height:46px;display:flex;justify-content:center;align-items: center;" >确定</button>
</view>
</view>
</view>
<!-- 固定的背景 -->
<view class='pupContentBG {{click?"showBG":"hideBG"}} {{option?"openBG":"closeBG"}}' catchtap='clickPup' catchtouchmove="myCatchTouch">
</view>

160
pages/logins/logins.wxss

@ -1,160 +0,0 @@
.pupContentBG {
width: 100vw !important;
height: 100vh !important;
position: fixed !important;
top: 0 !important;
}
.pupContent {
width: 100% !important;
background: #FFFFFF !important;
position: fixed !important;
bottom: 0 !important;
z-index: 999 !important;
border-radius: 16rpx 16rpx 0rpx 0rpx !important;
}
.pupContent >image {
width: 28rpx !important;
height: 28rpx !important;
float: right !important;
margin-right: 30rpx !important;
margin-top: 30rpx !important;
}
.pupContent-body {
margin: 60rpx 40rpx !important;
}
/* 设置显示的背景 */
.pupContent-head {
display: flex !important;
align-items: center !important;
color: #020202 !important;
font-weight:bold !important;
font-size:34rpx !important;
padding-bottom: 60rpx !important;
}
.pupContent-head view{
padding-left: 20rpx !important;
}
.pupContent-head image{
width: 80rpx !important;
height: 80rpx !important;
}
.showBG {
display: block !important;
}
.pupContent-title {
color: #020202 !important;
font-size: 30rpx !important;
font-weight:500 !important;
padding-bottom: 40rpx !important;
}
.pupContent-title {
color: #020202 !important;
font-size:30rpx !important;
}
.pupContent-btn {
height: 90rpx !important;
background-color: #1AAD19 !important;
color: #FFFFFF !important;
font-size:30rpx !important;
font-weight:500 !important;
display: flex !important;
justify-content: center !important;
align-items: center !important;
border-radius:10rpx !important;
}
.pupContent-con {
color: #666666 !important;
font-size:26rpx !important;
padding-bottom: 68rpx !important;
}
.hideBG {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideBGtUp {
from {
background: transparent;
}
to {
background: rgba(0, 0, 0, 0.1);
}
}
@keyframes slideBGDown {
from {
background: rgba(0, 0, 0, 0.1);
}
to {
background: transparent;
}
}
/* 显示或关闭内容时动画 */
.openBG {
animation: slideBGtUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.closeBG {
animation: slideBGDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
/* 设置显示内容 */
.showContent {
display: block;
}
.hideContent {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideContentUp {
from {
height: 0;
}
to {
height: 520rpx;
}
}
@keyframes slideContentDown {
from {
height: 520rpx;
}
to {
height: 0;
}
}
/* 显示或关闭内容时动画 */
.open {
animation: slideContentUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.closes {
animation: slideContentDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}

1
pages/logistics/logistics.js

@ -1,5 +1,6 @@
// pages/logistics/logistics.js // pages/logistics/logistics.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**

77
pages/new/new.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
current: 0, current: 0,
@ -23,41 +24,28 @@ Page({
sort: 0,// 1 asc 升序 0 desc 降序 sort: 0,// 1 asc 升序 0 desc 降序
}, },
onPullDownRefresh: function () { onPullDownRefresh: function () {
wx.showNavigationBarLoading() //在标题栏中显示加载 wx.showNavigationBarLoading() //在标题栏中显示加载
var that = this; var that = this;
var objectId = that.data.objectId; var objectId = that.data.objectId;
var select = that.data.select; var select = that.data.select;
var sort = that.data.sort; var sort = that.data.sort;
wx.request({ WXAPI.newProduct({
url: app.d.ceshiUrl + '&action=product&m=new_product',
method: 'post',
data: {
page: 1, page: 1,
cid: 1, cid: 1,
select: select, select: select,
sort: sort, sort: sort,
}, }).then(res => {
header: { if (res.status == 1) {
'content-type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
var shoplist = res.data.pro;
that.setData({ that.setData({
shopList: shoplist, shopList: data.pro,
page:2, page:2,
period: false period: false
}) })
wx.hideNavigationBarLoading() //完成停止加载 wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新 wx.stopPullDownRefresh() //停止下拉刷新
},
error: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}) });
}, },
/* tab */ /* tab */
choosesort1: function (e) { choosesort1: function (e) {
@ -189,32 +177,20 @@ Page({
var sort = that.data.sort; var sort = that.data.sort;
var page = that.data.page; var page = that.data.page;
//ajax请求数据 //ajax请求数据
wx.request({ WXAPI.newProduct({
url: app.d.ceshiUrl + '&action=product&m=new_product',
method: 'post',
data: {
cid: 1, cid: 1,
select: select, select: select,
sort: sort, sort: sort,
page: page page: page
}, }).then(res => {
header: { if (res.status == 1) {
'content-type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
var shoplist = res.data.pro;
that.setData({ that.setData({
shopList: shoplist, shopList: data.pro,
page: page+1 page: page+1
}) })
},
error: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}) });
}, },
//页面加载完成函数 //页面加载完成函数
onReady: function () { onReady: function () {
@ -230,21 +206,15 @@ Page({
that.setData({ that.setData({
page: page+1 page: page+1
}); });
wx.request({ WXAPI.newProduct({
url: app.d.ceshiUrl + '&action=product&m=new_product',
method: 'post',
data: {
page: page, page: page,
cid: 1, cid: 1,
select: select, select: select,
sort: sort, sort: sort,
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
}, if (data.pro == '' || data.status == 0) {
success: function (res) {
var prolist = res.data.pro;
if (prolist == '' || res.data.status == 0) {
that.setData({ that.setData({
period: true, period: true,
loading:false loading:false
@ -256,17 +226,10 @@ Page({
that.setData({ that.setData({
remind: '', remind: '',
loading:false, loading:false,
shopList: that.data.shopList.concat(prolist) shopList: that.data.shopList.concat(data.pro)
});
},
fail: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
}); });
} }
}) });
}, },
onShow: function () { onShow: function () {
var cont = this.data.cont; var cont = this.data.cont;

3
pages/notice/index.js

@ -1,5 +1,6 @@
var WxParse = require('../../wxParse/wxParse.js');
var app = getApp() var app = getApp()
var WxParse = require('../../wxParse/wxParse.js');
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
notice: [], notice: [],

1
pages/notice/notice.js

@ -1,4 +1,5 @@
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
notice: [], notice: [],

3
pages/order/detail.js

@ -1,7 +1,6 @@
var app = getApp(); var app = getApp();
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
//获取应用实例 var WXAPI = require('../../utils/server.js');
var common = require("../../utils/common.js");
function countdown(that) { function countdown(that) {
// 渲染倒计时时钟 // 渲染倒计时时钟

2
pages/order/order.js

@ -1,6 +1,6 @@
//获取应用实例 //获取应用实例
var app = getApp(); var app = getApp();
var common = require("../../utils/common.js"); var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
winWidth: 0, winWidth: 0,

1
pages/order/pay.js

@ -1,5 +1,6 @@
var app = getApp(); var app = getApp();
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
ispayOrder: false, ispayOrder: false,

8
pages/product/detail.js

@ -1,7 +1,7 @@
//获取应用实例 //获取应用实例
var app = getApp(); var app = getApp();
var util = require('../../utils/util.js') var util = require('../../utils/util.js')
var WXAPI = require('../../utils/server.js');
//引入这个插件,使html内容自动转换成wxml内容 //引入这个插件,使html内容自动转换成wxml内容
var WxParse = require('../../wxParse/wxParse.js'); var WxParse = require('../../wxParse/wxParse.js');
Page({ Page({
@ -606,7 +606,7 @@ Page({
} else { } else {
wx.showToast({ wx.showToast({
icon: 'loading', icon: 'loading',
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
} }
@ -725,7 +725,7 @@ Page({
that.data.itemData.isCollect = false; that.data.itemData.isCollect = false;
} else { } else {
wx.showToast({ wx.showToast({
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
that.setData({ that.setData({
@ -769,7 +769,7 @@ Page({
}) })
} else { } else {
wx.showToast({ wx.showToast({
title: data.err, title: res.err,
duration: 2000 duration: 2000
}); });
that.setData({ that.setData({

2
pages/product/detail.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "商品详情", "navigationBarTitleText": "商品详情",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

1
pages/return_goods/index.js

@ -1,5 +1,6 @@
// pages/return_goods/index.js // pages/return_goods/index.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
function initSubMenuDisplay() { function initSubMenuDisplay() {
return ['hidden', 'hidden', 'hidden']; return ['hidden', 'hidden', 'hidden'];
} }

1
pages/return_goods/return_goods.js

@ -1,5 +1,6 @@
// pages/return_goods/return_goods.js // pages/return_goods/return_goods.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**

28
pages/search/search.js

@ -1,5 +1,6 @@
var WxSearch = require('../../wxSearch/wxSearch.js')
var app = getApp(); var app = getApp();
var WxSearch = require('../../wxSearch/wxSearch.js')
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
color:'', color:'',
@ -19,31 +20,20 @@ Page({
}, },
search: function (e) { search: function (e) {
var that = this; var that = this;
wx.request({ WXAPI.searchIndex({
url: app.d.ceshiUrl + '&action=search&m=index',
method: 'post',
data: {
keyword:'百货' keyword:'百货'
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
},
success: function (res) {
that.setData({ that.setData({
cateItems: res.data.List, cateItems: data.List,
hotwords: res.data.hot, hotwords: data.hot,
curNav: res.data.List[0].cate_id curNav: data.List[0].cate_id
}); });
that.onReady(); that.onReady();
that.setData({ that.setData({
remind: '' remind: ''
}); });
},
fail: function () {
wx.showToast({
title: '网络异常!',
duration: 2000
});
} }
}); });
}, },

4
pages/search/search.wxml

@ -39,7 +39,7 @@
<!--左侧栏--> <!--左侧栏-->
<view class="nav_left"> <view class="nav_left">
<scroll-view scroll-y="true" style="height:99%;"> <scroll-view scroll-y="true" style="height:99%;">
<view wx:for="{{cateItems}}"> <view wx:for="{{cateItems}}" wx:key="cateItems">
<!--当前项的id等于item项的id,那个就是当前状态--> <!--当前项的id等于item项的id,那个就是当前状态-->
<!--用data-index记录这个数据在数组的下标位置,使用data-id设置每个item的id值,供打开2级页面使用--> <!--用data-index记录这个数据在数组的下标位置,使用data-id设置每个item的id值,供打开2级页面使用-->
<view class="nav_left_items {{curNav == item.cate_id ? 'active' : ''}}" bindtap="switchRightTab" data-index="{{index}}" data-id="{{item.cate_id}}">{{item.cate_name}}</view> <view class="nav_left_items {{curNav == item.cate_id ? 'active' : ''}}" bindtap="switchRightTab" data-index="{{index}}" data-id="{{item.cate_id}}">{{item.cate_name}}</view>
@ -52,7 +52,7 @@
<!--如果有数据,才遍历项--> <!--如果有数据,才遍历项-->
<image class='cimages' wx:if="{{cateItems[curIndex].cimgurl != ''}}" src="{{cateItems[curIndex].cimgurl}}"></image> <image class='cimages' wx:if="{{cateItems[curIndex].cimgurl != ''}}" src="{{cateItems[curIndex].cimgurl}}"></image>
<view wx:if="{{cateItems[curIndex].ishaveChild}}"> <view wx:if="{{cateItems[curIndex].ishaveChild}}">
<block wx:for="{{cateItems[curIndex].children}}"> <block wx:for="{{cateItems[curIndex].children}}" wx:key="children">
<view class="nav_right_items"> <view class="nav_right_items">
<!--界面跳转 --> <!--界面跳转 -->
<navigator url="../listdetail/listdetail?class={{item.child_id}}&title={{item.name}}" > <navigator url="../listdetail/listdetail?class={{item.child_id}}&title={{item.name}}" >

1
pages/set/set.js

@ -1,5 +1,6 @@
// pages/set/set.js // pages/set/set.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
}, },

1
pages/share/index.js

@ -1,5 +1,6 @@
// pages/share/index.js // pages/share/index.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
flag: false flag: false

2
pages/share/index.json

@ -1,7 +1,7 @@
{ {
"navigationBarBackgroundColor": "#999999", "navigationBarBackgroundColor": "#999999",
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "来客推", "navigationBarTitleText": "互利商城",
"backgroundColor": "#eeeeee", "backgroundColor": "#eeeeee",
"backgroundTextStyle": "light" "backgroundTextStyle": "light"
} }

2
pages/share/share.js

@ -1,6 +1,6 @@
// pages/share/share.js // pages/share/share.js
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**

1
pages/sign_in/sign_in.js

@ -1,5 +1,6 @@
var app = getApp(); var app = getApp();
var WxParse = require('../../wxParse/wxParse.js'); var WxParse = require('../../wxParse/wxParse.js');
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
showModal: false, showModal: false,

1
pages/user/recharge.js

@ -1,5 +1,6 @@
// pages/user/recharge.js // pages/user/recharge.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
fmoney: 0, fmoney: 0,

3
pages/user/score.js

@ -1,6 +1,7 @@
// pages/user/score.js // pages/user/score.js
var WxParse = require('../../wxParse/wxParse.js');
var app = getApp() var app = getApp()
var WxParse = require('../../wxParse/wxParse.js');
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
winWidth: 0, winWidth: 0,

1
pages/user/transfer1.js

@ -1,5 +1,6 @@
// pages/user/transfer1.js // pages/user/transfer1.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据

1
pages/user/transfer_jifen.js

@ -1,5 +1,6 @@
// pages/user/transfer_jifen.js // pages/user/transfer_jifen.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据

53
pages/user/user.js

@ -1,5 +1,6 @@
// pages/user/user.js // pages/user/user.js
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
pop: null, pop: null,
@ -97,40 +98,31 @@ Page({
requestMyData: function () { requestMyData: function () {
var that = this; var that = this;
wx.request({ WXAPI.userIndex({
url: app.d.ceshiUrl + '&action=user&m=index',
method: 'post',
data: {
openid: app.globalData.userInfo.openid || '', openid: app.globalData.userInfo.openid || '',
referee_openid: app.globalData.userInfo.referee_openid || '' referee_openid: app.globalData.userInfo.referee_openid || ''
}, }).then(res => {
header: { if (res.status == 1) {
'Content-Type': 'application/x-www-form-urlencoded' var data = res;
}, if (data.user.wx_name == 'undefined') {
success: function (res) {
console.log(res, 1111)
var status = res.data.status;
if (status == 1) {
var user = res.data.user;
if (user.wx_name == 'undefined') {
that.setData({ that.setData({
userlogin: true userlogin: true
}); });
that.login(); that.login();
} else { } else {
that.setData({ that.setData({
user: user, user: data.user,
article: res.data.article, article: data.article,
logo: res.data.logo, logo: data.logo,
company: res.data.company, company: data.company,
th: res.data.th, th: data.th,
dfh_num: res.data.dfh_num, dfh_num: data.dfh_num,
dfk_num: res.data.dfk_num, dfk_num: data.dfk_num,
dpj_num: res.data.dpj_num, dpj_num: data.dpj_num,
dsh_num: res.data.dsh_num, dsh_num: data.dsh_num,
plug_ins: res.data.plug_ins, plug_ins: data.plug_ins,
tjr: res.data.tjr, tjr: data.tjr,
support: res.data.support support: data.support
}); });
} }
} else { } else {
@ -139,13 +131,6 @@ Page({
duration: 2000 duration: 2000
}); });
} }
},
error: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
}); });
}, },
go: function (e) { go: function (e) {
@ -155,7 +140,7 @@ Page({
url: url url: url
}) })
}, },
logins: function () { login: function () {
if (app.userlogin(1)) { if (app.userlogin(1)) {
this.pop.clickPup(this) this.pop.clickPup(this)
this.requestMyData(); this.requestMyData();

2
pages/user/user.json

@ -1,6 +1,6 @@
{ {
"navigationBarTitleText": "个人中心", "navigationBarTitleText": "个人中心",
"usingComponents": { "usingComponents": {
"pop": "../logins/logins" "pop": "../login/login"
} }
} }

8
pages/user/user.wxml

@ -40,7 +40,7 @@
</view> </view>
</block> </block>
<block wx:else> <block wx:else>
<view class='logins' bindtap="logins">点击登录/注册</view> <view class='login' bindtap="login">点击登录/注册</view>
</block> </block>
</view> </view>
@ -117,7 +117,7 @@
</view> </view>
<!-- 功能列表 --> <!-- 功能列表 -->
<view class="function" style='background:#fff'> <view class="function" style='background:#fff'>
<block wx:for="{{plug_ins}}" wx:key="{{item.id}}"> <block wx:for="{{plug_ins}}" wx:key="id">
<view class="function_list" catchtap='jumpgo' data-id="{{item.subtitle_url}}"> <view class="function_list" catchtap='jumpgo' data-id="{{item.subtitle_url}}">
<view class='function_left'> <view class='function_left'>
<image style="width: 25px;height: 25px;margin: auto;" src='{{item.subtitle_image}}'></image> <image style="width: 25px;height: 25px;margin: auto;" src='{{item.subtitle_image}}'></image>
@ -130,7 +130,7 @@
</block> </block>
</view> </view>
<view class="function" style='background:#fff'> <view class="function" style='background:#fff'>
<block wx:for="{{list}}" wx:key="{{item.id}}"> <block wx:for="{{list}}" wx:key="id">
<navigator class="function_list" catchtap='jumpgo' data-id="../{{item.url}}"> <navigator class="function_list" catchtap='jumpgo' data-id="../{{item.url}}">
<view class='function_left'> <view class='function_left'>
@ -145,7 +145,7 @@
</block> </block>
</view> </view>
<view class="hh" > <view class="hh" >
<navigator url="../article/article?id={{item.Article_id}}" wx:for="{{article}}" wx:key="{{item.Article_id}}"> <navigator url="../article/article?id={{item.Article_id}}" wx:for="{{article}}" wx:key="Article_id">
<view class="qbdd mt10 jiantou"> <view class="qbdd mt10 jiantou">
<view class="font_14 c3">{{item.Article_title}}</view> <view class="font_14 c3">{{item.Article_title}}</view>
<view class="fl_r c9 font_12 l_h20 text-length" hover-class="none" style="margin-right: 5px;height: 100%;"> <view class="fl_r c9 font_12 l_h20 text-length" hover-class="none" style="margin-right: 5px;height: 100%;">

2
pages/user/user.wxss

@ -350,7 +350,7 @@ border-radius:5px;
line-height:40px; line-height:40px;
padding:9px; padding:9px;
} }
.logins { .login {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;

1
pages/user/wallet.js

@ -1,4 +1,5 @@
var app = getApp(); var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({ Page({
data: { data: {
winWidth: 0, winWidth: 0,

1
pages/user/withdrawals.js

@ -1,4 +1,5 @@
var app = getApp() var app = getApp()
var WXAPI = require('../../utils/server.js');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据

2
project.config.json

@ -17,7 +17,7 @@
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.9.1", "libVersion": "2.9.1",
"appid": "wxd1d2f92514ae4c0c", "appid": "wx8b3b4ae60c5d5d92",
"projectname": "%E6%9D%A5%E5%AE%A2%E7%94%B5%E5%95%86", "projectname": "%E6%9D%A5%E5%AE%A2%E7%94%B5%E5%95%86",
"simulatorType": "wechat", "simulatorType": "wechat",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},

5
project.private.config.json

@ -1,7 +1,8 @@
{ {
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "%E6%9D%A5%E5%AE%A2%E7%94%B5%E5%95%86", "projectname": "%E4%BA%92%E5%88%A9%E5%95%86%E5%9F%8E",
"setting": { "setting": {
"compileHotReLoad": true "compileHotReLoad": true
} },
"libVersion": "2.20.2"
} }

16
request.js

@ -1,16 +0,0 @@
var util = require('./utils/util.js')
var request = new Object();
request.wxRequest = function (obj) {
wx.request({
url: util.getUri() + obj.url,
data: obj.data,
method: obj.method,
header: { "Content-Type": "application/x-www-form-urlencoded" },
success: function (res) {
typeof (obj.success) == 'function' && obj.success(res.data);
}
})
}
module.exports = request

133
utils/server.js

@ -0,0 +1,133 @@
//小程序开发api接口
const API_BASE_URL = 'http://xiaochengxu.houjiemeishi.com/zhibo/LKT/index.php?module=api&software_name=3&edition=1.0'
const requestServer = (url, method, data) => {
let _url = API_BASE_URL + url
return new Promise((resolve, reject) => {
var userInfo = wx.getStorageSync('userInfo');
var token = userInfo.token;
var openid = wx.getStorageSync('openid');
// console.log('token:' + token);
wx.request({
url: _url,
method: method,
data: data,
header: {
'content-type': 'application/x-www-form-urlencoded',
token: token,
openid: openid,
},
dataType: 'json',
success(res) {
resolve(res.data)
},
fail(error) {
reject(error)
},
complete(aaa) {
//加载完成
}
})
})
}
//promise
Promise.prototype.finally = function(callback) {
var Promise = this.constructor
return this.then(
function(value) {
Promise.resolve(callback()).then(
function() {
return value;
}
);
},
function(reason) {
Promise.resolve(callback()).then(
function() {
throw reason;
}
);
}
)
}
module.exports = {
requestServer,
appIndex: (data) => { //获取用户会话密钥
return requestServer('&action=app&m=index', 'post', data)
},
homeIndex: (data) => { //首页
return requestServer('&action=Index&m=index', 'post', data)
},
appCart: (data) => {
return requestServer('&action=app&m=cart', 'post', data)
},
productSaveFormid: (data) => {
return requestServer('&action=product&m=save_formid', 'post', data)
},
userMaterial: (data) => { //用户信息
return requestServer('&action=user&m=material', 'post', data)
},
indexGetMore: (data) => { //更多
return requestServer('&action=Index&m=get_more', 'post', data)
},
newProduct: (data) => { //新品
return requestServer('&action=product&m=new_product', 'post', data)
},
searchIndex: (data) => { //搜索页
return requestServer('&action=search&m=index', 'post', data)
},
productToCollection: (data) => {
return requestServer('&action=product&m=to_Collection', 'post', data)
},
userIndex: (data) => { //个人中心
return requestServer('&action=user&m=index', 'post', data)
},
productUpcart: (data) => {
return requestServer('&action=product&m=up_cart', 'post', data)
},
productDelAllCart: (data) => { //清空
return requestServer('&action=product&m=delAll_cart', 'post', data)
},
productShopping: (data) => {
return requestServer('&action=product&m=Shopping', 'post', data)
},
productDelcart: (data) => { //删除
return requestServer('&action=product&m=delcart', 'post', data)
},
addressManagement: (data) => { //添加地址
return requestServer('&action=user&m=AddressManagement', 'post', data)
},
getCityArr: (data) => { //根据省获取市
return requestServer('&action=user&m=getCityArr', 'post', data)
},
getCountyInfo: (data) => { //根据省市获取县
return requestServer('&action=user&m=getCountyInfo', 'post', data)
},
preservation: (data) => {
return requestServer('&action=user&m=Preservation', 'post', data)
},
saveAddress: (data) => {
return requestServer('&action=user&m=SaveAddress', 'post', data)
},
addressDelselect: (data) => {
return requestServer('&action=address&m=del_select', 'post', data)
},
addressIndex: (data) => {
return requestServer('&action=address&m=index', 'post', data)
},
addressSetDefault: (data) => { //设置默认地址
return requestServer('&action=address&m=set_default', 'post', data)
},
addressDelAdds: (data) => { //删除地址
return requestServer('&action=address&m=del_adds', 'post', data)
},
addressUpAddsIndex: (data) => { //修改地址
return requestServer('&action=address&m=up_addsindex', 'post', data)
},
addressUpAdds: (data) => { //修改地址
return requestServer('&action=address&m=up_adds', 'post', data)
},
}

58
utils/util.js

@ -1,3 +1,4 @@
var WXAPI = require('./server.js');
function formatTime(date) { function formatTime(date) {
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() + 1 var month = date.getMonth() + 1
@ -14,69 +15,46 @@ function formatNumber(n) {
} }
function getUesrBg(that) { function getUesrBg(that) {
wx.request({ WXAPI.appCart({
url: that.d.ceshiUrl + '&action=app&m=cart', openid: app.globalData.userInfo.openid,
method: 'post', }).then(res => {
data: { if (res.status == 1) {
openid: that.globalData.userInfo.openid, var data = res;
var num = data.cart.toString()
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var num = res.data.cart.toString()
if (num > 0) { if (num > 0) {
wx.setTabBarBadge({ wx.setTabBarBadge({
index: 3, index: 3,
text: num, text: num,
}) })
} }
}
},
fail: function (e) {
},
}); });
} }
function getUesrBgplus(that, app, is) { function getUesrBgplus(that, app, is) {
wx.request({ WXAPI.appCart({
url: app.d.ceshiUrl + '&action=app&m=cart',
method: 'post',
data: {
openid: app.globalData.userInfo.openid, openid: app.globalData.userInfo.openid,
}).then(res => {
}, if (res.status == 1) {
header: { var data = res;
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
if (is) { if (is) {
that.setData({ that.setData({
cart: res.data.cart cart: data.cart
}) })
return null return null
} }
if (res.data.cart) { if (data.cart) {
wx.setTabBarBadge({ wx.setTabBarBadge({
index: 3, index: 3,
text: res.data.cart, text: data.cart,
}) })
} else { } else {
wx.removeTabBarBadge({ wx.removeTabBarBadge({
index: 3 index: 3
}) })
} }
}
},
fail: function (e) {
},
}); });
} }
@ -84,7 +62,7 @@ function getUesrBgplus(that, app, is) {
* 假设你访问的后台登录路径是https://www.baidu.com/LKT/index.php?module=Login * 假设你访问的后台登录路径是https://www.baidu.com/LKT/index.php?module=Login
* 那么你在这里填的路径应该是https://www.baidu.com/LKT/index.php?module=api&software_name=3&edition=1.0 * 那么你在这里填的路径应该是https://www.baidu.com/LKT/index.php?module=api&software_name=3&edition=1.0
*/ */
function getUri() { function getUrl() {
//如果不想安装后台服务,请使用注释这一行做简单数据体验 //如果不想安装后台服务,请使用注释这一行做简单数据体验
return 'http://xiaochengxu.houjiemeishi.com/zhibo/LKT/index.php?module=api&software_name=3&edition=1.0' return 'http://xiaochengxu.houjiemeishi.com/zhibo/LKT/index.php?module=api&software_name=3&edition=1.0'
// return 'http://localhost/open/app/LKT/index.php?module=api&software_name=3&edition=1.0' // return 'http://localhost/open/app/LKT/index.php?module=api&software_name=3&edition=1.0'
@ -94,7 +72,7 @@ module.exports = {
formatTime: formatTime, formatTime: formatTime,
getUesrBg: getUesrBg, getUesrBg: getUesrBg,
getUesrBgplus: getUesrBgplus, getUesrBgplus: getUesrBgplus,
getUri: getUri getUrl: getUrl
} }
function checkStringEmpty(data) { function checkStringEmpty(data) {

6
wxSearch/wxSearch.wxml

@ -4,7 +4,7 @@
<view class="wxSearchMindKey"> <view class="wxSearchMindKey">
<view class="wxSearchMindKeyList"> <view class="wxSearchMindKeyList">
<block wx:for="{{wxSearchData.mindKeys}}"> <block wx:for="{{wxSearchData.mindKeys}}" wx:key="mindKeys">
<view class="wxSearchMindKeyItem" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</view> <view class="wxSearchMindKeyItem" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</view>
</block> </block>
</view> </view>
@ -13,7 +13,7 @@
<view class="wxSearchKey" style="display:{{wxSearchData.view.isShowSearchKey ? 'block':'none'}}"> <view class="wxSearchKey" style="display:{{wxSearchData.view.isShowSearchKey ? 'block':'none'}}">
<text class="wxSearchTitle">热门搜索</text> <text class="wxSearchTitle">热门搜索</text>
<view class="wxSearchKeyList"> <view class="wxSearchKeyList">
<block wx:for="{{wxSearchData.keys}}"> <block wx:for="{{wxSearchData.keys}}" wx:key="keys">
<view class="wxSearchKeyItem" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</view> <view class="wxSearchKeyItem" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</view>
</block> </block>
</view> </view>
@ -27,7 +27,7 @@
</view> </view>
<view style='clear:both;'></view> <view style='clear:both;'></view>
<view wx:if="{{wxSearchData.his[0]}}" class="wxSearchKeyList"> <view wx:if="{{wxSearchData.his[0]}}" class="wxSearchKeyList">
<block wx:for="{{wxSearchData.his}}"> <block wx:for="{{wxSearchData.his}}" wx:key="wxSearchData.his">
<view class="wxSearchKeyItem"> <view class="wxSearchKeyItem">
<text class="wxSearchHistoryItemText" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</text> <text class="wxSearchHistoryItemText" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</text>
</view> </view>

Loading…
Cancel
Save