diff --git a/app.js b/app.js index 435128c..f48f8cf 100644 --- a/app.js +++ b/app.js @@ -178,7 +178,7 @@ App({ }, globalData:{ userInfo:null, - apiurl:"https://vip.agqyjs.com",//"http://localhost:8080",//http://localhost:24382 //https://vip.agqyjs.com + apiurl:"http://localhost:24382",//"http://localhost:8080",//http://localhost:24382 //https://vip.agqyjs.com IFRefreshCart:0, IFRefreshsell:0, IFRefreshsell0:0, diff --git a/app.json b/app.json index 7aa36d1..665ac68 100644 --- a/app.json +++ b/app.json @@ -118,6 +118,9 @@ "permission": { "scope.userLocation": { "desc": "你的位置信息将用于标注自提地址距离" + }, + "scope.writePhotosAlbum": { + "desc": "保存二维码到相册,方便分享给好友" } }, "debug": true, diff --git a/pages/my/index.js b/pages/my/index.js index 8fe8852..7dce3d0 100644 --- a/pages/my/index.js +++ b/pages/my/index.js @@ -140,7 +140,7 @@ Page({ { icon: '../../images/my_ico1.png', url: (userInfo.sjuLevel0 == 2 ? '../mybusiness0/index' : (userInfo.sjuLevel0 == 1 ? '' : '../appbusiness0/index')), - text: (userInfo.sjuLevel0 == 2 ? '事业部管理' : (userInfo.sjuLevel0 == 1 ? '申请健康驿站正在审核中...' : '申请健康驿站')) + text: (userInfo.sjuLevel0 == 2 ? '健康驿站管理' : (userInfo.sjuLevel0 == 1 ? '申请健康驿站正在审核中...' : '申请健康驿站')) }, { icon: '../../images/my_ico3.png', diff --git a/pages/mybusiness/index.js b/pages/mybusiness/index.js index 88d4250..ccf842f 100644 --- a/pages/mybusiness/index.js +++ b/pages/mybusiness/index.js @@ -107,8 +107,51 @@ Page( { that.setData({ savetitle:"保存中,请稍候..." }) + + // 检查权限 + wx.getSetting({ + success: function(res) { + if (!res.authSetting['scope.writePhotosAlbum']) { + // 未授权,请求授权 + wx.authorize({ + scope: 'scope.writePhotosAlbum', + success: function() { + // 授权成功,执行保存 + that.saveImage(); + }, + fail: function() { + // 授权失败,引导用户去设置 + wx.showModal({ + title: '提示', + content: '需要授权保存到相册权限', + confirmText: '去授权', + success: function(res) { + if (res.confirm) { + wx.openSetting({ + success: function(settingRes) { + if (settingRes.authSetting['scope.writePhotosAlbum']) { + that.saveImage(); + } + } + }) + } + } + }) + } + }) + } else { + // 已授权,直接保存 + that.saveImage(); + } + } + }) + }, + + // 提取保存图片的逻辑到单独函数 + saveImage: function() { var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") + wx.canvasToTempFilePath({ canvasId: "myCanvas", destWidth: 520, @@ -140,30 +183,11 @@ Page( { }, fail: function(err) { console.log('saveImageToPhotosAlbum fail:', err); - if (err.errMsg.indexOf('auth deny') > -1 || err.errMsg.indexOf('authorize') > -1) { - wx.showModal({ - title: '提示', - content: '需要授权保存到相册权限', - confirmText: '去授权', - success: function (res) { - if (res.confirm) { - wx.openSetting({ - success: function(settingRes) { - if (settingRes.authSetting['scope.writePhotosAlbum']) { - that.onxz(e); - } - } - }) - } - } - }) - } else { - wx.showToast({ - title: '保存失败:' + err.errMsg, - icon: "none", - duration: 3000 - }) - } + wx.showToast({ + title: '保存失败:' + err.errMsg, + icon: "none", + duration: 3000 + }) that.setData({ savetitle:"保存商家收款码到相册" }) diff --git a/pages/mybusiness0/index.wxml b/pages/mybusiness0/index.wxml index b2aad26..1f4d157 100644 --- a/pages/mybusiness0/index.wxml +++ b/pages/mybusiness0/index.wxml @@ -52,7 +52,7 @@ - + 自提订单全部订单 diff --git a/pages/myorder/index.js b/pages/myorder/index.js index 1e7e6df..95478ee 100644 --- a/pages/myorder/index.js +++ b/pages/myorder/index.js @@ -556,8 +556,10 @@ Page( { }) },onorderdetail:function(e) { var id = e.currentTarget.dataset.id + //var orderid ="26032416461968"; wx.navigateTo({ url: "../myorderinfo/index?id=" + id + "&t=" + that.data.t + //url: "../myorderinfo/index?orderid=" + orderid + "&t=" + that.data.t }) },ondetail:function(e) { var id = e.currentTarget.dataset.id diff --git a/pages/mytgm/index.js b/pages/mytgm/index.js index 72798f9..f4b819d 100644 --- a/pages/mytgm/index.js +++ b/pages/mytgm/index.js @@ -156,6 +156,48 @@ Page( { that.setData({ savetitle:"保存中,请稍候..." }) + + // 检查权限 + wx.getSetting({ + success: function(res) { + if (!res.authSetting['scope.writePhotosAlbum']) { + // 未授权,请求授权 + wx.authorize({ + scope: 'scope.writePhotosAlbum', + success: function() { + // 授权成功,执行保存 + that.saveImage(); + }, + fail: function() { + // 授权失败,引导用户去设置 + wx.showModal({ + title: '提示', + content: '需要授权保存到相册权限', + confirmText: '去授权', + success: function(res) { + if (res.confirm) { + wx.openSetting({ + success: function(settingRes) { + if (settingRes.authSetting['scope.writePhotosAlbum']) { + that.saveImage(); + } + } + }) + } + } + }) + } + }) + } else { + // 已授权,直接保存 + that.saveImage(); + } + } + }) + }, + + // 提取保存图片的逻辑到单独函数 + saveImage: function() { var userId = wx.getStorageSync("userId") var LoginId = wx.getStorageSync("LoginId") @@ -190,30 +232,11 @@ Page( { }, fail: function(err) { console.log('saveImageToPhotosAlbum fail:', err); - if (err.errMsg.indexOf('auth deny') > -1 || err.errMsg.indexOf('authorize') > -1) { - wx.showModal({ - title: '提示', - content: '需要授权保存到相册权限', - confirmText: '去授权', - success: function (res) { - if (res.confirm) { - wx.openSetting({ - success: function(settingRes) { - if (settingRes.authSetting['scope.writePhotosAlbum']) { - that.onsavepic(e); - } - } - }) - } - } - }) - } else { - wx.showToast({ - title: '保存失败:' + err.errMsg, - icon: "none", - duration: 3000 - }) - } + wx.showToast({ + title: '保存失败:' + err.errMsg, + icon: "none", + duration: 3000 + }) that.setData({ savetitle:"保存二维码到相册" }) @@ -232,7 +255,6 @@ Page( { }) } }) - },onsavepic0: function() { /*wx.saveImageToPhotosAlbum({ diff --git a/pages/qhaddress/index.js b/pages/qhaddress/index.js index 7ef5ae2..0249724 100644 --- a/pages/qhaddress/index.js +++ b/pages/qhaddress/index.js @@ -8,11 +8,37 @@ Page( { onLoad: function() { that = this - var addresss = JSON.parse(wx.getStorageSync("addresss")) - that.setData({ - loadingHidden:true, - myaddress:addresss + + that = this + wx.setBackgroundColor({ + backgroundColor: "#96C6F5", + }) + that.clearCache();//清本页缓存 + that.getlist(0);//第一次加载数据 + var sopenFrame0=setInterval(function (){ + clearInterval(sopenFrame0); + wx.getLocation({ + type: 'gcj02', // 比较精确 + success: (res) => { + wx.setStorageSync("latitude", res.latitude) + wx.setStorageSync("longitude", res.longitude) + that.clearCache();//清本页缓存 + that.getlist(0); + },fail: (err) => { + /*wx.showToast({ + title: JSON.stringify(err), + icon: "none", + duration: 20000 + })*/ + } + }) + },1000); + // var addresss = JSON.parse(wx.getStorageSync("addresss")) + // that.setData({ + // loadingHidden:true, + // myaddress:addresss + // }) } ,select:function(e) { var index = e.currentTarget.dataset.id @@ -20,11 +46,101 @@ Page( { var type=that.data.myaddress[index].type var contact=that.data.myaddress[index].contact var tel=that.data.myaddress[index].tel + var area=that.data.myaddress[index].area var address=that.data.myaddress[index].address var distance=that.data.myaddress[index].distance - app.globalData.selladdress0={addressId:addressId,type:type,contact:contact,tel:tel,address:address,distance:distance} + app.globalData.selladdress0={addressId:addressId,type:type,contact:contact,tel:tel,area:area,address:address,distance:distance} app.globalData.IFRefreshsell0=1 wx.navigateBack({}) - } + }, + // 清缓存 + clearCache:function(){ + that.setData({ + Start: 0, + loadingHidden:false + }); +}, getlist: function (gp) { + + var userId = wx.getStorageSync("userId") + var LoginId = wx.getStorageSync("LoginId") + var latitude = wx.getStorageSync("latitude") + var longitude = wx.getStorageSync("longitude") + + wx.request({ + url: app.globalData.apiurl + "/xapiajax.ashx", + data: { + action:"getBusinessdata", + userId:(!userId?"":userId), + LoginId:(!LoginId?"":LoginId), + // keyword:that.data.keyword, + t:(that.data.nav>0?that.data.nav:""), + Start:that.data.Start, + latitude:(!latitude?"":latitude), + longitude:(!longitude?"":longitude), + }, + method:"GET", + dataType:"json", + header: { + "content-type": "application/json" // 默认值 + }, + success (res) { + if(res.data.status==1){ + var tmpArr = null; + if(gp==0||gp==1){ + tmpArr = res.data.Businesslist + }else{ + tmpArr = that.data.business; + tmpArr.push.apply(tmpArr,res.data.Businesslist); + } + // 转换Businesslist数据为myaddress期望的格式 + var myaddressData = res.data.Businesslist.map(function(item) { + return { + id: item._id, + contact: item.name, + tel: item.phone, + area: '', + address: item.address, + distance: item.distance + }; + }); + that.setData({ + business: tmpArr, + myaddress: myaddressData, + Start: that.data.Start+res.data.Businesslist.length, + loadingHidden:true + }) + if(gp==0||gp==1){ + that.setData({ + navData:res.data.lbs + }) + if(res.data.Businesslist.length==0){ + that.setData({ + nodataHidden:false + }) + }else{ + that.setData({ + nodataHidden:true + }) + } + } + } + else{ + if(res.data.msg=="您未登录"){ + wx.removeStorageSync('userId') + wx.removeStorageSync('LoginId') + } + } + if(gp==0||gp==1){ + //隐藏loading 提示框 + wx.hideLoading(); + //隐藏导航条加载动画 + wx.hideNavigationBarLoading(); + //停止下拉刷新 + wx.stopPullDownRefresh(); + + } + } + }) +}, }) diff --git a/pages/sell/index.js b/pages/sell/index.js index 94fad5b..2d1eba1 100644 --- a/pages/sell/index.js +++ b/pages/sell/index.js @@ -634,7 +634,7 @@ Page( { name:that.data.a_name, tel:that.data.a_tel, agentid:that.data.agentid, - agenttype:that.data.agenttype, + agenttype:(!that.data.agenttype?1:that.data.agenttype), Guests:Guests, image:that.data.image, image0:that.data.image0 @@ -683,11 +683,11 @@ Page( { //JSON.stringify(res) console.log('开始微信支付:',res); wx.showToast({ - title: "用户取消", + title: "支付失败", icon: "none", - duration: 3000 + duration: 1000 }) - wx.navigateBack({}) + //wx.navigateBack({}) } }) }