Browse Source

更新部分网络请求方法

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

5
app.json

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

10
app.wxss

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

116
pages/address/address.js

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

128
pages/address/index.js

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

1
pages/bangding/bangding.js

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

136
pages/cart/cart.js

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

1
pages/collection/collection.js

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

1
pages/comment/comment.js

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

2
pages/coupon/index.js

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

2
pages/coupon/index.json

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

8
pages/distribution/detail.js

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

2
pages/distribution/detail.json

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

1
pages/distribution/list.js

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

1
pages/distribution/user.js

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

1
pages/envelope/envelope.js

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

1
pages/footprint/footprint.js

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

1
pages/group_buy/cantuan.js

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

2
pages/group_buy/cantuan.json

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

1
pages/group_buy/comment.js

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

4
pages/group_buy/detail.js

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

2
pages/group_buy/detail.json

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

1
pages/group_buy/group.js

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

2
pages/group_buy/group.json

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

1
pages/group_buy/payfor.js

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

208
pages/index/index.js

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

5
pages/index/index.json

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

6
pages/index/index.wxml

@ -47,7 +47,7 @@
<view class='tab'>
<scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}">
<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>
</view>
</view>
@ -57,12 +57,12 @@
</view>
</view>
<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">
<!-- /首页轮播图/ -->
<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}}'>
<swiper-item>
<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;
}
.title-bar { position: relative; border-bottom: 1rpx solid #eee; height: 100rpx;margin-bottom:10px; }
.title-bar wx-image { width: 38rpx; height: 38rpx; }
.title-bar .title { margin: 0 40rpx; }

1
pages/listdetail/listdetail.js

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

1
pages/live/index.js

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

78
pages/login/login.js

@ -1,21 +1,59 @@
var app = getApp();
var WXAPI = require('../../utils/server.js');
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,
})
}
},
onUnload: function() {
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: "正在登录",
@ -29,7 +67,6 @@ Page({
var nickName = userInfo.nickName;
var avatarUrl = userInfo.avatarUrl;
var gender = userInfo.gender; //性别 0:未知、1:男、2:女
// console.log(res.userInfo)
wx.request({
url: app.d.ceshiUrl + '&action=user&m=material',
method: 'post',
@ -59,7 +96,7 @@ Page({
title: '正在登入',
success: 2000
});
// console.log(e.detail.userInfo)
console.log(e.detail.userInfo)
if (e.detail.errMsg == 'getUserInfo:ok') {
//获取成功设置状态
app.globalData.userlogin = true;
@ -78,6 +115,7 @@ Page({
that.setData({
userlogin: false
})
that.getOP(e.detail.userInfo)
} else {
wx.showToast({
@ -143,16 +181,21 @@ Page({
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',
@ -170,15 +213,18 @@ Page({
title: '授权成功!',
success: 2000
});
setTimeout(function () {
wx.navigateBack({
delta: 1
})
that.clickPup()
thatplus.onLoad()
}, 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 style="padding: 0 60rpx">
<view style="padding:80rpx 0 48rpx;border-bottom: 1rpx solid #e3e3e3;margin-bottom: 72rpx;text-align: center">
<image src="/images/icon-wechatapp.png" style="width: 200rpx;height: 200rpx;"></image>
<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 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>

164
pages/login/login.wxss

@ -1,4 +1,160 @@
body{ background: #fff; }
.login-btn{ border: none; height: 88rpx; line-height: 88rpx; background: #04be01; color: #fff; font-size: 11pt; border-radius: 999rpx; }
.login-btn::after{ display: none; }
.login-btn.button-hover { box-shadow: inset 0 5rpx 30rpx rgba(0,0,0,.15); }
.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 执行的动作。 */
}

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
var app = getApp();
var WXAPI = require('../../utils/server.js');
Page({
/**

77
pages/new/new.js

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

3
pages/notice/index.js

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

1
pages/notice/notice.js

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

3
pages/order/detail.js

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

2
pages/order/order.js

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

1
pages/order/pay.js

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

8
pages/product/detail.js

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

2
pages/product/detail.json

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

1
pages/return_goods/index.js

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

1
pages/return_goods/return_goods.js

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

28
pages/search/search.js

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

4
pages/search/search.wxml

@ -39,7 +39,7 @@
<!--左侧栏-->
<view class="nav_left">
<scroll-view scroll-y="true" style="height:99%;">
<view wx:for="{{cateItems}}">
<view wx:for="{{cateItems}}" wx:key="cateItems">
<!--当前项的id等于item项的id,那个就是当前状态-->
<!--用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>
@ -52,7 +52,7 @@
<!--如果有数据,才遍历项-->
<image class='cimages' wx:if="{{cateItems[curIndex].cimgurl != ''}}" src="{{cateItems[curIndex].cimgurl}}"></image>
<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">
<!--界面跳转 -->
<navigator url="../listdetail/listdetail?class={{item.child_id}}&title={{item.name}}" >

1
pages/set/set.js

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

1
pages/share/index.js

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

2
pages/share/index.json

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

2
pages/share/share.js

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

1
pages/sign_in/sign_in.js

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

1
pages/user/recharge.js

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

3
pages/user/score.js

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

1
pages/user/transfer1.js

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

1
pages/user/transfer_jifen.js

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

53
pages/user/user.js

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

2
pages/user/user.json

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

8
pages/user/user.wxml

@ -40,7 +40,7 @@
</view>
</block>
<block wx:else>
<view class='logins' bindtap="logins">点击登录/注册</view>
<view class='login' bindtap="login">点击登录/注册</view>
</block>
</view>
@ -117,7 +117,7 @@
</view>
<!-- 功能列表 -->
<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_left'>
<image style="width: 25px;height: 25px;margin: auto;" src='{{item.subtitle_image}}'></image>
@ -130,7 +130,7 @@
</block>
</view>
<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}}">
<view class='function_left'>
@ -145,7 +145,7 @@
</block>
</view>
<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="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%;">

2
pages/user/user.wxss

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

1
pages/user/wallet.js

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

1
pages/user/withdrawals.js

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

2
project.config.json

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

5
project.private.config.json

@ -1,7 +1,8 @@
{
"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": {
"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) {
var year = date.getFullYear()
var month = date.getMonth() + 1
@ -14,69 +15,46 @@ function formatNumber(n) {
}
function getUesrBg(that) {
wx.request({
url: that.d.ceshiUrl + '&action=app&m=cart',
method: 'post',
data: {
openid: that.globalData.userInfo.openid,
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var num = res.data.cart.toString()
WXAPI.appCart({
openid: app.globalData.userInfo.openid,
}).then(res => {
if (res.status == 1) {
var data = res;
var num = data.cart.toString()
if (num > 0) {
wx.setTabBarBadge({
index: 3,
text: num,
})
}
},
fail: function (e) {
},
}
});
}
function getUesrBgplus(that, app, is) {
wx.request({
url: app.d.ceshiUrl + '&action=app&m=cart',
method: 'post',
data: {
WXAPI.appCart({
openid: app.globalData.userInfo.openid,
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
}).then(res => {
if (res.status == 1) {
var data = res;
if (is) {
that.setData({
cart: res.data.cart
cart: data.cart
})
return null
}
if (res.data.cart) {
if (data.cart) {
wx.setTabBarBadge({
index: 3,
text: res.data.cart,
text: data.cart,
})
} else {
wx.removeTabBarBadge({
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=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://localhost/open/app/LKT/index.php?module=api&software_name=3&edition=1.0'
@ -94,7 +72,7 @@ module.exports = {
formatTime: formatTime,
getUesrBg: getUesrBg,
getUesrBgplus: getUesrBgplus,
getUri: getUri
getUrl: getUrl
}
function checkStringEmpty(data) {

6
wxSearch/wxSearch.wxml

@ -4,7 +4,7 @@
<view class="wxSearchMindKey">
<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>
</block>
</view>
@ -13,7 +13,7 @@
<view class="wxSearchKey" style="display:{{wxSearchData.view.isShowSearchKey ? 'block':'none'}}">
<text class="wxSearchTitle">热门搜索</text>
<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>
</block>
</view>
@ -27,7 +27,7 @@
</view>
<view style='clear:both;'></view>
<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">
<text class="wxSearchHistoryItemText" bindtap="wxSearchKeyTap" data-key="{{item}}">{{item}}</text>
</view>

Loading…
Cancel
Save