diff --git a/app.js b/app.js index 4335a48..c651837 100644 --- a/app.js +++ b/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: { - 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; + WXAPI.appIndex({ + code: code, + nickName: stype.nickName, + avatarUrl: stype.avatarUrl, + gender: stype.gender, + referee_openid: this.globalData.userInfo.referee_openid || '' + }).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); + } }); }, diff --git a/app.json b/app.json index f6143e8..5d68335 100644 --- a/app.json +++ b/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 }, diff --git a/app.wxss b/app.wxss index 6d56e29..4ca4d9b 100644 --- a/app.wxss +++ b/app.wxss @@ -1,9 +1,11 @@ /**app.wxss**/ -page{ - background: #fff; font-family: '微软雅黑' - } +page { + background: #fff; font-family: '微软雅黑'; + height:100%; + width:100%; +} .container { height: 100%; display: flex; @@ -171,12 +173,6 @@ color:#FFFFFF; background-color:#d9002f; } -page{ - height:100%; - width:100%; -} - - /* /加载页面/ */ .body{ background-color: #f2f2f2; diff --git a/pages/address/address.js b/pages/address/address.js index 389adef..f3e0136 100644 --- a/pages/address/address.js +++ b/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: { - 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 - }); - } + 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) { @@ -139,90 +134,67 @@ Page({ // 根据省获取市 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; + WXAPI.getCityArr({ + count: count, + }).then(res => { + if (res.status == 1) { + var data = res; that.setData({ - shi: shi + shi: data.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 - }); - } + 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; - 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 - }); - } + 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) { @@ -252,49 +224,35 @@ Page({ mobile = e.detail.value.mobile; //预处理验证手机号码 if (mobile.match(/^\d{11}$/)) { - wx.request({ - url: app.d.ceshiUrl + '&action=user&m=SaveAddress', - data: { - openid: app.globalData.userInfo.openid, - user_name: e.detail.value.user_name, - 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 { - app.d.islogin = true; - wx.showToast({ - title: res.data.info, - icon: 'success', - duration: 1000 - }); - //成功后返回上一页面 - wx.navigateBack({ - delta: 1 - }); - } - }, - fail: function () { - // fail + WXAPI.saveAddress({ + openid: app.globalData.userInfo.openid, + user_name: e.detail.value.user_name, + 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.showToast({ - title: '网络异常!', - duration: 2000 + title: data.info, + icon: 'loading', + duration: 1500 + }) + } else { + app.d.islogin = true; + wx.showToast({ + title: data.info, + icon: 'success', + duration: 1000 + }); + //成功后返回上一页面 + wx.navigateBack({ + delta: 1 }); } - }) + }); } else { wx.showToast({ title: '手机号码格式错误,请重新输入!', diff --git a/pages/address/index.js b/pages/address/index.js index a4ef4c7..88c62d7 100644 --- a/pages/address/index.js +++ b/pages/address/index.js @@ -1,4 +1,5 @@ var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ data: { address: [], @@ -29,38 +30,27 @@ Page({ content: '你确认移除吗?', success: function (res) { if (res.confirm) { - console.log(11) - wx.request({ - url: app.d.ceshiUrl + '&action=address&m=del_select', - data: { - 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) { - wx.showToast({ - title: res.data.succ, - duration: 2000 - }); - that.setData({ - flag: false, - }); - that.DataonLoad(); - - } else { - wx.showToast({ - title: res.data.err, - duration: 2000 - }); - } - }, - }); + WXAPI.addressDelselect({ + openid: app.globalData.userInfo.openid, + id_arr: carts + }).then(res => { + if (res.status == 1) { + var data = res; + wx.showToast({ + title: '地址已清空', + duration: 2000 + }); + that.setData({ + flag: false, + }); + that.DataonLoad(); + } else { + wx.showToast({ + title: res.err, + duration: 2000 + }); + } + }); } else { that.DataonLoad(); that.setData({ @@ -99,19 +89,12 @@ Page({ } else { var cartId = 0; } - - wx.request({ - url: app.d.ceshiUrl + '&action=address&m=index', - data: { - 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; + WXAPI.addressIndex({ + openid: app.globalData.userInfo.openid + }).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,42 +215,27 @@ 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: { - 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; + WXAPI.addressSetDefault({ + openid: app.globalData.userInfo.openid, + addr_id: addrId + }).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 - }) - return false; - } - wx.showToast({ - title: res.data.err, - duration: 2000 - }); - that.DataonLoad(); - } else { - wx.showToast({ - title: res.data.err, - duration: 2000 - }); + if (cartId != '0' || cartId == 'group') { + wx.navigateBack({ + delta: 1 + }) + return false; } - }, - fail: function () { - // fail wx.showToast({ - title: '网络异常!', + title: '设置成功', + duration: 2000 + }); + that.DataonLoad(); + } else { + wx.showToast({ + 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: { - 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) { - that.DataonLoad(); - } else { - wx.showToast({ - title: res.data.err, - duration: 2000 - }); - } - }, - fail: function () { - // fail + res.confirm && WXAPI.addressDelAdds({ + openid: app.globalData.userInfo.openid, + id_arr: addrId + }).then(res => { + if (res.status == 1) { + that.DataonLoad(); + } else { 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: { - 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; + WXAPI.addressIndex({ + openid: app.globalData.userInfo.openid, + }).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, }) }, }) \ No newline at end of file diff --git a/pages/address/index.wxml b/pages/address/index.wxml index ffd416b..db20464 100644 --- a/pages/address/index.wxml +++ b/pages/address/index.wxml @@ -12,7 +12,7 @@ {{item.tel}} {{item.address_xq}} - + @@ -39,7 +39,7 @@ - + 编辑 diff --git a/pages/address/upaddress.js b/pages/address/upaddress.js new file mode 100644 index 0000000..2453a4a --- /dev/null +++ b/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 + }) +} \ No newline at end of file diff --git a/pages/address/upaddress/upaddress.json b/pages/address/upaddress.json similarity index 100% rename from pages/address/upaddress/upaddress.json rename to pages/address/upaddress.json diff --git a/pages/address/upaddress/upaddress.wxml b/pages/address/upaddress.wxml similarity index 100% rename from pages/address/upaddress/upaddress.wxml rename to pages/address/upaddress.wxml diff --git a/pages/address/upaddress/upaddress.wxss b/pages/address/upaddress.wxss similarity index 100% rename from pages/address/upaddress/upaddress.wxss rename to pages/address/upaddress.wxss diff --git a/pages/address/upaddress/upaddress.js b/pages/address/upaddress/upaddress.js deleted file mode 100644 index a17c8ec..0000000 --- a/pages/address/upaddress/upaddress.js +++ /dev/null @@ -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 - }) -} \ No newline at end of file diff --git a/pages/article/article.js b/pages/article/article.js index c51edee..22f3fa5 100644 --- a/pages/article/article.js +++ b/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({ diff --git a/pages/bangding/bangding.js b/pages/bangding/bangding.js index 863c9e9..85ee38c 100644 --- a/pages/bangding/bangding.js +++ b/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 = "-"; diff --git a/pages/cart/cart.js b/pages/cart/cart.js index 86afa62..40aeb2c 100644 --- a/pages/cart/cart.js +++ b/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,42 +41,26 @@ Page({ duration: 2000 }); } else { - wx.request({ - url: app.d.ceshiUrl + '&action=product&m=up_cart', - method: 'post', - data: { - 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) { - util.getUesrBgplus(that, app, false) - // 只有大于一件的时候,才能normal状态,否则disable状态 - var minusStatus = num <= 1 ? 'disabled' : 'normal'; - // 购物车数据 - var carts = that.data.carts; - carts[index].num = num; - // 按钮可用状态 - var minusStatuses = that.data.minusStatuses; - minusStatuses[index] = minusStatus; - // 将数值与状态写回 - that.setData({ - minusStatuses: minusStatuses - }); - that.sum(); - } - }, - fail: function () { - // fail - wx.showToast({ - title: '网络异常!', - duration: 2000 + WXAPI.productUpcart({ + user_id: that.data.user_id, + num: num, + cart_id: cart_id + }).then(res => { + if (res.status == 1) { + util.getUesrBgplus(that, app, false) + // 只有大于一件的时候,才能normal状态,否则disable状态 + var minusStatus = num <= 1 ? 'disabled' : 'normal'; + // 购物车数据 + var carts = that.data.carts; + carts[index].num = num; + // 按钮可用状态 + var minusStatuses = that.data.minusStatuses; + minusStatuses[index] = minusStatus; + // 将数值与状态写回 + that.setData({ + minusStatuses: minusStatuses }); + that.sum(); } }); } @@ -94,31 +79,22 @@ Page({ content: '你确认清空全部吗?', success: function (res) { if (res.confirm) { - wx.request({ - url: app.d.ceshiUrl + '&action=product&m=delAll_cart', - method: 'post', - data: { - 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) { - wx.showToast({ - title: '操作成功!', - duration: 2500 - }); - that.loadProductData(); - util.getUesrBgplus(that, app, false) - } else { - wx.showToast({ - title: '操作失败!', - duration: 2000 - }); - } - }, + WXAPI.productDelAllCart({ + user_id: that.data.user_id, + }).then(res => { + if (res.status == 1) { + wx.showToast({ + title: '操作成功!', + duration: 2500 + }); + that.loadProductData(); + util.getUesrBgplus(that, app, false) + } else { + wx.showToast({ + title: '操作失败!', + duration: 2000 + }); + } }); } }, @@ -189,33 +165,23 @@ Page({ }); return false; } - //ajax请求 - wx.request({ - url: app.d.ceshiUrl + '&action=product&m=to_Collection', - method: 'post', - data: { - user_id: that.data.user_id, - carts: toastStr, - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - util.getUesrBgplus(that, app, false) - var data = res.data; - if (data.status == 1) { - wx.showToast({ - title: '操作成功!', - duration: 2000 - }); - that.loadProductData(); - } else { - wx.showToast({ - title: '操作失败!', - duration: 2000 - }); - } - }, + WXAPI.productToCollection({ + user_id: that.data.user_id, + carts: toastStr, + }).then(res => { + util.getUesrBgplus(that, app, false) + if (res.status == 1) { + wx.showToast({ + title: '操作成功!', + duration: 2000 + }); + that.loadProductData(); + } else { + wx.showToast({ + title: '操作失败!', + duration: 2000 + }); + } }); }, @@ -229,41 +195,26 @@ 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: { - 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) { - util.getUesrBgplus(that, app, false) - // 只有大于一件的时候,才能normal状态,否则disable状态 - var minusStatus = num <= 1 ? 'disabled' : 'normal'; - // 购物车数据 - var carts = that.data.carts; - carts[index].num = num; - // 按钮可用状态 - var minusStatuses = that.data.minusStatuses; - minusStatuses[index] = minusStatus; - // 将数值与状态写回 - that.setData({ - minusStatuses: minusStatuses - }); - that.sum(); - } - }, - fail: function () { - wx.showToast({ - title: '网络异常!', - duration: 2000 + WXAPI.productUpcart({ + user_id: that.data.user_id, + num: num, + cart_id: cart_id + }).then(res => { + if (res.status == 1) { + util.getUesrBgplus(that, app, false) + // 只有大于一件的时候,才能normal状态,否则disable状态 + var minusStatus = num <= 1 ? 'disabled' : 'normal'; + // 购物车数据 + var carts = that.data.carts; + carts[index].num = num; + // 按钮可用状态 + var minusStatuses = that.data.minusStatuses; + minusStatuses[index] = minusStatus; + // 将数值与状态写回 + that.setData({ + minusStatuses: minusStatuses }); + that.sum(); } }); } else { @@ -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: { - carts: carts, - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - util.getUesrBgplus(that, app, false) - //--init data - var data = res.data; - if (data.status == 1) { - that.loadProductData(); - - } else { - wx.showToast({ - title: '操作失败!', - duration: 2000 - }); - } - }, + res.confirm && WXAPI.productDelcart({ + carts: carts, + }).then(res => { + util.getUesrBgplus(that, app, false) + if (res.status == 1) { + that.loadProductData(); + } + 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: { - user_id: app.globalData.userInfo.openid - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - var cart = res.data.cart; + + WXAPI.productShopping({ + user_id: app.globalData.userInfo.openid + }).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,40 +407,25 @@ 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: { - 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) { - // 只有大于一件的时候,才能normal状态,否则disable状态 - var minusStatus = num <= 1 ? 'disabled' : 'normal'; - // 购物车数据 - var carts = that.data.carts; - carts[index].num = num; - // 按钮可用状态 - var minusStatuses = that.data.minusStatuses; - minusStatuses[index] = minusStatus; - // 将数值与状态写回 - that.setData({ - minusStatuses: minusStatuses - }); - that.sum(); - } - }, - fail: function () { - wx.showToast({ - title: '网络异常!', - duration: 2000 + WXAPI.productUpcart({ + user_id: that.data.user_id, + num: num, + cart_id: carid + }).then(res => { + if (res.status == 1) { + // 只有大于一件的时候,才能normal状态,否则disable状态 + var minusStatus = num <= 1 ? 'disabled' : 'normal'; + // 购物车数据 + var carts = that.data.carts; + carts[index].num = num; + // 按钮可用状态 + var minusStatuses = that.data.minusStatuses; + minusStatuses[index] = minusStatus; + // 将数值与状态写回 + that.setData({ + minusStatuses: minusStatuses }); + that.sum(); } }); } else { diff --git a/pages/collection/collection.js b/pages/collection/collection.js index 5f9543c..a04c0d4 100644 --- a/pages/collection/collection.js +++ b/pages/collection/collection.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { remind: '加载中', diff --git a/pages/comment/comment.js b/pages/comment/comment.js index 82f37a0..b372a1d 100644 --- a/pages/comment/comment.js +++ b/pages/comment/comment.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); var that; Page({ data: { diff --git a/pages/coupon/index.js b/pages/coupon/index.js index f4f9bfe..cc2b6f1 100644 --- a/pages/coupon/index.js +++ b/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, diff --git a/pages/coupon/index.json b/pages/coupon/index.json index 1fac7ec..8f11dd7 100644 --- a/pages/coupon/index.json +++ b/pages/coupon/index.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "优惠券", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/distribution/detail.js b/pages/distribution/detail.js index e20270b..4c5fac1 100644 --- a/pages/distribution/detail.js +++ b/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({ diff --git a/pages/distribution/detail.json b/pages/distribution/detail.json index 4438a65..25aca8e 100644 --- a/pages/distribution/detail.json +++ b/pages/distribution/detail.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "商品详情", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/distribution/list.js b/pages/distribution/list.js index f75f33b..da6e59e 100644 --- a/pages/distribution/list.js +++ b/pages/distribution/list.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { current: 0, diff --git a/pages/distribution/user.js b/pages/distribution/user.js index d572702..64bc3ed 100644 --- a/pages/distribution/user.js +++ b/pages/distribution/user.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { winWidth: 0, diff --git a/pages/envelope/envelope.js b/pages/envelope/envelope.js index e62b403..a7a3fa4 100644 --- a/pages/envelope/envelope.js +++ b/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({ diff --git a/pages/footprint/footprint.js b/pages/footprint/footprint.js index 47304db..2d6f3c9 100644 --- a/pages/footprint/footprint.js +++ b/pages/footprint/footprint.js @@ -1,4 +1,5 @@ var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ data: { remind: '加载中', diff --git a/pages/group_buy/cantuan.js b/pages/group_buy/cantuan.js index 1809d8e..68b346b 100644 --- a/pages/group_buy/cantuan.js +++ b/pages/group_buy/cantuan.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { pop: null, diff --git a/pages/group_buy/cantuan.json b/pages/group_buy/cantuan.json index e202599..0a2d570 100644 --- a/pages/group_buy/cantuan.json +++ b/pages/group_buy/cantuan.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "我的团", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/group_buy/comment.js b/pages/group_buy/comment.js index 786a50f..6568320 100644 --- a/pages/group_buy/comment.js +++ b/pages/group_buy/comment.js @@ -1,5 +1,6 @@ // pages/group_buy/comment.js var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ /** diff --git a/pages/group_buy/detail.js b/pages/group_buy/detail.js index 12051a9..6cbdc1b 100644 --- a/pages/group_buy/detail.js +++ b/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, diff --git a/pages/group_buy/detail.json b/pages/group_buy/detail.json index 4438a65..25aca8e 100644 --- a/pages/group_buy/detail.json +++ b/pages/group_buy/detail.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "商品详情", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/group_buy/group.js b/pages/group_buy/group.js index b206978..46aecb9 100644 --- a/pages/group_buy/group.js +++ b/pages/group_buy/group.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { pop: null, diff --git a/pages/group_buy/group.json b/pages/group_buy/group.json index 952e18f..7b8aed9 100644 --- a/pages/group_buy/group.json +++ b/pages/group_buy/group.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "爱拼才会赢", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/group_buy/payfor.js b/pages/group_buy/payfor.js index ce83624..1e0a5ba 100644 --- a/pages/group_buy/payfor.js +++ b/pages/group_buy/payfor.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); function initSubMenuDisplay() { return ['hidden', 'hidden', 'hidden']; diff --git a/pages/index/index.js b/pages/index/index.js index 8e897e9..9430a13 100644 --- a/pages/index/index.js +++ b/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: { - page: page, - index: index, - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - var prolist = res.data.prolist; + WXAPI.indexGetMore({ + page: page, + index: index, + }).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: { - from_id: formId, - userid: app.globalData.userInfo.openid - }, - method: 'post', - success: function (res) { - - } - }) + WXAPI.productSaveFormid({ + from_id: formId, + userid: app.globalData.userInfo.openid + }).then(res => { + + }); } }, search: function () { @@ -174,128 +159,62 @@ 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; - 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: '' }); - console.log(res.data.list.length) - if (res.data.list.length) { - that.listnsg(); - } - - }, - fail: function (e) { - 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 - }); + 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 = data.notice; + var indexTwoData = twoList[0].twodata // 获取首页的数据对象 - 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(); - } + app.globalData.logoimg = data.logo + app.globalData.title = 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: data.logo, + djname: data.djname, + zjList: data.list + }); - }, - fail: function (e) { - wx.showToast({ - title: '网络异常!', - duration: 2000 - }); - }, - }) - } + wx.setNavigationBarColor({ + frontColor: app.d.frontColor, + backgroundColor: app.d.bgcolor //页面标题为路由参数 + }); + wx.setNavigationBarTitle({ + title: title, + success: function () { }, + }); + that.setData({ remind: '' }); + console.log(data.list.length) + if (data.list.length) { + that.listnsg(); + } + // } + // else { + // that.showToast(data.err); + // } + }); }, 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: { - openid: app.globalData.userInfo.openid, - nickName: nickName, - avatarUrl: avatarUrl, - gender: gender - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { + WXAPI.userMaterial({ + openid: app.globalData.userInfo.openid, + nickName: nickName, + avatarUrl: avatarUrl, + gender: gender + }).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('转发失败') } } diff --git a/pages/index/index.json b/pages/index/index.json index d1ffc8f..e6a04cd 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -1,5 +1,6 @@ { "usingComponents": { - "pop": "../logins/logins" - } + "pop": "../login/login" + }, + "navigationBarTitleText": "互利商城" } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 5e778b1..151b789 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -47,7 +47,7 @@ - + {{item.name}} @@ -57,12 +57,12 @@ - + - + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index f58e88e..2aa8b36 100644 --- a/pages/index/index.wxss +++ b/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; } diff --git a/pages/listdetail/listdetail.js b/pages/listdetail/listdetail.js index 835505f..ccf39bf 100644 --- a/pages/listdetail/listdetail.js +++ b/pages/listdetail/listdetail.js @@ -1,4 +1,5 @@ var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ data: { current: 0, diff --git a/pages/live/index.js b/pages/live/index.js index 8e00720..697e182 100644 --- a/pages/live/index.js +++ b/pages/live/index.js @@ -1,5 +1,6 @@ // pages/live/index.js var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ /** diff --git a/pages/login/login.js b/pages/login/login.js index e0a064f..2acdb91 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -1,21 +1,59 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ - data: {}, - onLoad: function(e) { - - }, - onReady: function() { - - }, - onShow: function() { - - }, - onHide: function() { - - }, - onUnload: function() { - - }, + + 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: "正在登录", @@ -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,42 +181,50 @@ Page({ getOP: function (res) { //提交用户信息 获取用户id let that = this - 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 () { - wx.navigateBack({ - delta: 1 - }) - }, 1800); + 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); + + } + }) - } }) - } + -}); \ No newline at end of file + } +}) \ No newline at end of file diff --git a/pages/login/login.json b/pages/login/login.json index 3a080f6..4575d1b 100644 --- a/pages/login/login.json +++ b/pages/login/login.json @@ -1 +1,4 @@ -{"navigationBarTitleText":"授权登录"} \ No newline at end of file +{ + "usingComponents": {}, + "component": true +} \ No newline at end of file diff --git a/pages/login/login.wxml b/pages/login/login.wxml index 4b94689..1537d3a 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -1,13 +1,28 @@ - - + - - - - - - 申请获取以下权限 - 获得你的公开信息(昵称、头像等) + + + + + + 欢迎来到{{ loadtitle }} + - + + 为提供更优质的服务,需要获取以下信息: + + + + · 你的公开信息(昵称、头像等) + + + + + + + + + + + \ No newline at end of file diff --git a/pages/login/login.wxss b/pages/login/login.wxss index 5cd6748..69135d0 100644 --- a/pages/login/login.wxss +++ b/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 执行的动作。 */ +} + diff --git a/pages/logins/logins.js b/pages/logins/logins.js deleted file mode 100644 index d675e82..0000000 --- a/pages/logins/logins.js +++ /dev/null @@ -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); - - } - }) - - }) - - - - } -}) \ No newline at end of file diff --git a/pages/logins/logins.json b/pages/logins/logins.json deleted file mode 100644 index 4575d1b..0000000 --- a/pages/logins/logins.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "usingComponents": {}, - "component": true -} \ No newline at end of file diff --git a/pages/logins/logins.wx.js b/pages/logins/logins.wx.js deleted file mode 100644 index 9727344..0000000 --- a/pages/logins/logins.wx.js +++ /dev/null @@ -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 () { - - } -}) \ No newline at end of file diff --git a/pages/logins/logins.wxml b/pages/logins/logins.wxml deleted file mode 100644 index eb43237..0000000 --- a/pages/logins/logins.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - 欢迎来到{{ loadtitle }} - - - - 为提供更优质的服务,需要获取以下信息: - - - - · 你的公开信息(昵称、头像等) - - - - - - - - - - - - \ No newline at end of file diff --git a/pages/logins/logins.wxss b/pages/logins/logins.wxss deleted file mode 100644 index 69135d0..0000000 --- a/pages/logins/logins.wxss +++ /dev/null @@ -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 执行的动作。 */ -} - diff --git a/pages/logistics/logistics.js b/pages/logistics/logistics.js index 39ace0b..e9aed77 100644 --- a/pages/logistics/logistics.js +++ b/pages/logistics/logistics.js @@ -1,5 +1,6 @@ // pages/logistics/logistics.js var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ /** diff --git a/pages/new/new.js b/pages/new/new.js index 497a087..87106c0 100644 --- a/pages/new/new.js +++ b/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: { - page: 1, - cid: 1, - select: select, - sort: sort, - }, - header: { - 'content-type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - var shoplist = res.data.pro; + WXAPI.newProduct({ + page: 1, + cid: 1, + select: select, + sort: sort, + }).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: { - cid: 1, - select: select, - sort: sort, - page: page - }, - header: { - 'content-type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - var shoplist = res.data.pro; + WXAPI.newProduct({ + cid: 1, + select: select, + sort: sort, + page: page + }).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: { - 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) { + WXAPI.newProduct({ + page: page, + cid: 1, + select: select, + sort: sort, + }).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; diff --git a/pages/notice/index.js b/pages/notice/index.js index d413662..05b5e2a 100644 --- a/pages/notice/index.js +++ b/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: [], diff --git a/pages/notice/notice.js b/pages/notice/notice.js index 20b8945..9c268ce 100644 --- a/pages/notice/notice.js +++ b/pages/notice/notice.js @@ -1,4 +1,5 @@ var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ data: { notice: [], diff --git a/pages/order/detail.js b/pages/order/detail.js index fa03818..67fe934 100644 --- a/pages/order/detail.js +++ b/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) { // 渲染倒计时时钟 diff --git a/pages/order/order.js b/pages/order/order.js index 5ce2116..d913942 100644 --- a/pages/order/order.js +++ b/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, diff --git a/pages/order/pay.js b/pages/order/pay.js index 01c7357..d422456 100644 --- a/pages/order/pay.js +++ b/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, diff --git a/pages/product/detail.js b/pages/product/detail.js index 5417c68..6b0e6e4 100644 --- a/pages/product/detail.js +++ b/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({ diff --git a/pages/product/detail.json b/pages/product/detail.json index 4438a65..25aca8e 100644 --- a/pages/product/detail.json +++ b/pages/product/detail.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "商品详情", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/return_goods/index.js b/pages/return_goods/index.js index 240a883..077ccb5 100644 --- a/pages/return_goods/index.js +++ b/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']; } diff --git a/pages/return_goods/return_goods.js b/pages/return_goods/return_goods.js index 20da64d..222e053 100644 --- a/pages/return_goods/return_goods.js +++ b/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({ /** diff --git a/pages/search/search.js b/pages/search/search.js index 9f026ee..b4d2ab7 100644 --- a/pages/search/search.js +++ b/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: { - keyword:'百货' - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { + WXAPI.searchIndex({ + keyword:'百货' + }).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 - }); } }); }, diff --git a/pages/search/search.wxml b/pages/search/search.wxml index 06d0c06..f433d53 100644 --- a/pages/search/search.wxml +++ b/pages/search/search.wxml @@ -39,7 +39,7 @@ - + {{item.cate_name}} @@ -52,7 +52,7 @@ - + diff --git a/pages/set/set.js b/pages/set/set.js index 5cd4800..64d7072 100644 --- a/pages/set/set.js +++ b/pages/set/set.js @@ -1,5 +1,6 @@ // pages/set/set.js var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ data: { }, diff --git a/pages/share/index.js b/pages/share/index.js index 8b8417e..9bbc294 100644 --- a/pages/share/index.js +++ b/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 diff --git a/pages/share/index.json b/pages/share/index.json index 2aab8ce..9153b28 100644 --- a/pages/share/index.json +++ b/pages/share/index.json @@ -1,7 +1,7 @@ { "navigationBarBackgroundColor": "#999999", "navigationBarTextStyle": "black", - "navigationBarTitleText": "来客推", + "navigationBarTitleText": "互利商城", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light" } \ No newline at end of file diff --git a/pages/share/share.js b/pages/share/share.js index 7846e55..58abbcc 100644 --- a/pages/share/share.js +++ b/pages/share/share.js @@ -1,6 +1,6 @@ // pages/share/share.js var app = getApp(); - +var WXAPI = require('../../utils/server.js'); Page({ /** diff --git a/pages/sign_in/sign_in.js b/pages/sign_in/sign_in.js index 377c4aa..fb90e42 100644 --- a/pages/sign_in/sign_in.js +++ b/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, diff --git a/pages/user/recharge.js b/pages/user/recharge.js index 901be29..46b31d7 100644 --- a/pages/user/recharge.js +++ b/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, diff --git a/pages/user/score.js b/pages/user/score.js index 9664727..e87b7e4 100644 --- a/pages/user/score.js +++ b/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, diff --git a/pages/user/transfer1.js b/pages/user/transfer1.js index b79fe8a..79b3c61 100644 --- a/pages/user/transfer1.js +++ b/pages/user/transfer1.js @@ -1,5 +1,6 @@ // pages/user/transfer1.js var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ /** * 页面的初始数据 diff --git a/pages/user/transfer_jifen.js b/pages/user/transfer_jifen.js index 40b6612..3d1cc3c 100644 --- a/pages/user/transfer_jifen.js +++ b/pages/user/transfer_jifen.js @@ -1,5 +1,6 @@ // pages/user/transfer_jifen.js var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ /** * 页面的初始数据 diff --git a/pages/user/user.js b/pages/user/user.js index c194f53..794b7a9 100644 --- a/pages/user/user.js +++ b/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, @@ -96,57 +97,41 @@ Page({ }, requestMyData: function () { - var that = this; - wx.request({ - url: app.d.ceshiUrl + '&action=user&m=index', - method: 'post', - data: { - 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') { - 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 - }); - } - } else { - wx.showToast({ - title: '非法操作!', - duration: 2000 - }); - } - }, - error: function (e) { + var that = this; + WXAPI.userIndex({ + openid: app.globalData.userInfo.openid || '', + referee_openid: app.globalData.userInfo.referee_openid || '' + }).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: 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 { wx.showToast({ - title: '网络异常!', + title: '非法操作!', duration: 2000 }); - } - }); + } + }); }, go: function (e) { console.log(e) @@ -155,7 +140,7 @@ Page({ url: url }) }, - logins: function () { + login: function () { if (app.userlogin(1)) { this.pop.clickPup(this) this.requestMyData(); diff --git a/pages/user/user.json b/pages/user/user.json index 3ee5423..69a93a6 100644 --- a/pages/user/user.json +++ b/pages/user/user.json @@ -1,6 +1,6 @@ { "navigationBarTitleText": "个人中心", "usingComponents": { - "pop": "../logins/logins" + "pop": "../login/login" } } \ No newline at end of file diff --git a/pages/user/user.wxml b/pages/user/user.wxml index ee401cf..9276d36 100644 --- a/pages/user/user.wxml +++ b/pages/user/user.wxml @@ -40,7 +40,7 @@ - 点击登录/注册 + @@ -117,7 +117,7 @@ - + @@ -130,7 +130,7 @@ - + @@ -145,7 +145,7 @@ - + {{item.Article_title}} diff --git a/pages/user/user.wxss b/pages/user/user.wxss index d6e5ddd..606e7a1 100644 --- a/pages/user/user.wxss +++ b/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; diff --git a/pages/user/wallet.js b/pages/user/wallet.js index 9348f85..36ddb27 100644 --- a/pages/user/wallet.js +++ b/pages/user/wallet.js @@ -1,4 +1,5 @@ var app = getApp(); +var WXAPI = require('../../utils/server.js'); Page({ data: { winWidth: 0, diff --git a/pages/user/withdrawals.js b/pages/user/withdrawals.js index b1fa83f..cdbdcc0 100644 --- a/pages/user/withdrawals.js +++ b/pages/user/withdrawals.js @@ -1,4 +1,5 @@ var app = getApp() +var WXAPI = require('../../utils/server.js'); Page({ /** * 页面的初始数据 diff --git a/project.config.json b/project.config.json index 8bb8300..d6ba4cd 100644 --- a/project.config.json +++ b/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": {}, diff --git a/project.private.config.json b/project.private.config.json index f0e0d39..634161e 100644 --- a/project.private.config.json +++ b/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" } \ No newline at end of file diff --git a/request.js b/request.js deleted file mode 100644 index 4b103ad..0000000 --- a/request.js +++ /dev/null @@ -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 diff --git a/utils/server.js b/utils/server.js new file mode 100644 index 0000000..7932e4a --- /dev/null +++ b/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) + }, + +} \ No newline at end of file diff --git a/utils/util.js b/utils/util.js index 7c23685..924b013 100644 --- a/utils/util.js +++ b/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: { - openid: app.globalData.userInfo.openid, - - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { + WXAPI.appCart({ + openid: app.globalData.userInfo.openid, + }).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) { diff --git a/wxSearch/wxSearch.wxml b/wxSearch/wxSearch.wxml index 9fae4a4..b44836e 100644 --- a/wxSearch/wxSearch.wxml +++ b/wxSearch/wxSearch.wxml @@ -4,7 +4,7 @@ - + {{item}} @@ -13,7 +13,7 @@ 热门搜索 - + {{item}} @@ -27,7 +27,7 @@ - + {{item}}