From 68153870e676fb1b45ddba4b7d769dec6f550d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B1=AA?= <781521347@qq.com> Date: Thu, 16 Dec 2021 10:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=AA=E8=8C=84h5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 35 +++--- common/config.js | 6 +- common/httpRequest.js | 2 +- common/jweixin.js | 205 ++++++++++++++++++++++------------- manifest.json | 18 +-- pages/index/index.vue | 6 +- pages/index/selectCampus.vue | 2 +- pages/index/tasksdetails.vue | 14 ++- pages/my/myVIP.vue | 64 +++++++---- pages/order/release.vue | 4 +- pages/public/login.vue | 3 + pagesB/pages/my/myVIP.vue | 2 +- project.config.json | 4 - 13 files changed, 226 insertions(+), 139 deletions(-) diff --git a/App.vue b/App.vue index 8da6430..25be24d 100644 --- a/App.vue +++ b/App.vue @@ -6,13 +6,13 @@ onLaunch: function() { let that = this; //获取全局邀请码 - that.$Request.getT('/common/type/88').then(res => { - if (res.code == 0) { - if (res.data && res.data.value) { - this.$queue.setData('publicRelation', res.data.value); - } - } - }); + // that.$Request.getT('/common/type/88').then(res => { + // if (res.code == 0) { + // if (res.data && res.data.value) { + // this.$queue.setData('publicRelation', res.data.value); + // } + // } + // }); // 微信单笔提现最大金额 that.$Request.getT('/common/type/86').then(res => { if (res.code == 0) { @@ -22,13 +22,13 @@ } }); // 粉丝福利号 - that.$Request.getT('/common/type/170').then(res => { - if (res.code == 0) { - if (res.data && res.data.value) { - this.$queue.setData('fensiImage', res.data.value); - } - } - }); + // that.$Request.getT('/common/type/170').then(res => { + // if (res.code == 0) { + // if (res.data && res.data.value) { + // this.$queue.setData('fensiImage', res.data.value); + // } + // } + // }); // 微信提现是否显示 that.$Request.getT('/common/type/168').then(res => { if (res.code == 0) { @@ -55,7 +55,11 @@ }); }, - onShow: function() { + onShow: function(e) { + if(e && e.query.code){ //h5微信公众号登录返回的code + let code = e.query.code + this.$queue.setData('wxCode', code); + } }, onHide: function() {} }; @@ -68,4 +72,5 @@ view{ box-sizing: border-box; } + diff --git a/common/config.js b/common/config.js index 54cdeb7..31b4b57 100644 --- a/common/config.js +++ b/common/config.js @@ -1,6 +1,8 @@ -// const ROOTPATH1 = "http://192.168.0.111:8891/sqx_fast"; -const ROOTPATH1 = "https://fanqie.app.cyjyyjy.com/sqx_fast"; +// const ROOTPATH1 = "http://10.11.32.109:8891/sqx_fast"; +// const ROOTPATH1 = "http://10.11.32.107:8891/sqx_fast"; +const ROOTPATH1 = "http://waimai.n.gznl.top/sqx_fast"; +// const ROOTPATH1 = "https://fanqie.app.cyjyyjy.com/sqx_fast"; const ROOTPATH = "https://bwc.xianmxkj.com/sqx_fast"; module.exports = { APIHOST: ROOTPATH, diff --git a/common/httpRequest.js b/common/httpRequest.js index 5664b53..8892d7b 100644 --- a/common/httpRequest.js +++ b/common/httpRequest.js @@ -59,7 +59,7 @@ module.exports = { "token": token }, success: function (result) { - console.error(result); + // console.error(result); succ.call(self, result.data) }, fail: function (e) { diff --git a/common/jweixin.js b/common/jweixin.js index 38158be..186964e 100644 --- a/common/jweixin.js +++ b/common/jweixin.js @@ -1,82 +1,139 @@ var jweixin = require('jweixin-module') +const userId = uni.getStorageSync('userId'); +console.log(userId,'userId') +import HttpRequest from '../common/httpRequest' export default { - //判断是否在微信中 - isWechat: function () { - var ua = window.navigator.userAgent.toLowerCase(); - if (ua.match(/micromessenger/i) == 'micromessenger') { - // console.log(‘是微信客户端‘) - return true; - } else { - // console.log(‘不是微信客户端‘) - return false; - } - }, - //初始化sdk配置 - initJssdkShare: function (callback, url) { - uni.request({ - url: 'http://licai.youma.me/index/wechat/', - method: 'GET', - data: { - url: 'http://licaifrot.youma.me/' - }, //这里不是统一的,看你们后端 - success: (res) => { - console.log(res) - if (res.statusCode == 200) { - let result = res.data.Data - console.log(result) - jweixin.config({ - debug: false, - appId: result.appId, - timestamp: result.timestamp, - nonceStr: result.nonceStr, - signature: result.signature, - jsApiList: [ - 'chooseWXPay', - 'checkJsApi', - 'updateTimelineShareData', - 'updateAppMessageShareData' - ] - }); - //配置完成后,再执行分享等功能 - if (callback) { - callback(result); - } - } - } - }); - }, - - //在需要自定义分享的页面中调用 - share: function (data, url) { - url = url ? url : window.location.href; - console.log("url:" + url) + //判断是否在微信中 + isWechat: function () { + var ua = window.navigator.userAgent.toLowerCase(); + if (ua.match(/micromessenger/i) == 'micromessenger') { + // console.log(‘是微信客户端‘) + return true; + } else { + // console.log(‘不是微信客户端‘) + return false; + } + }, + //初始化sdk配置 + initJssdkShare: function (callback, url) { + HttpRequest.getT('/appLogin/jsapiInit',{url: url}).then((result)=>{ + if(result.code == 0){ + jweixin.config({ + debug: false, + appId: result.appId, + timestamp: result.timestamp, + nonceStr: result.nonceStr, + signature: result.signature, + jsApiList: [ + 'chooseWXPay', + 'checkJsApi', + 'updateTimelineShareData', + 'updateAppMessageShareData', + 'getLocation' + ] + }); + if (callback) { + callback(result); + } + } + }) + }, + share: function (data, url) { + url = url ? url : window.location.href; + console.log("url:" + url) + if (!this.isWechat()) { + uni.showToast({ + title: '不在微信客户端', + icon: 'none' + }) + return; + } + //每次都需要重新初始化配置,才可以进行分享 + this.initJssdkShare(function (signData) { + jweixin.ready(function () { + var shareData = { + title: data && data.title ? data.title : signData.site_name, + desc: data && data.desc ? data.desc : signData.site_description, + link: url, + imgUrl: data && data.img ? data.img : signData.site_logo, + success: function (res) { + // 分享后的一些操作,比如分享统计等等 + }, + cancel: function (res) {} + }; + //分享给朋友接口 + jweixin.updateAppMessageShareData(shareData); + //分享到朋友圈接口 + // jweixin.updateTimelineShareData(shareData); + }); + }, url) + }, + wxChatWebPay: function (url) { + if (!this.isWechat()) { + uni.showToast({ + title: '不在微信客户端', + icon: 'none' + }) + return; + } + return new Promise((resolve,reject)=>{ + //每次都需要重新初始化配置 + this.initJssdkShare(function () { + jweixin.ready(function () { + HttpRequest.postT('/api/order/wxPayMember?userId=' + userId + '&type=3').then((orderInfo)=>{ + jweixin.chooseWXPay({ + nonceStr: orderInfo.noncestr, + timestamp: orderInfo.timestamp, + package: orderInfo.package, + signType: orderInfo.signType, + paySign: orderInfo.sign, + success: (res) => { + console.log('支付成功') + resolve(res) + }, + fail: (res)=> { + reject(res) + console.log('支付失败') + }, + cancel: (res)=> { + resolve(res) + console.log('取消支付') + } + }) + }) + + }); + },url) + }) + }, + wxGetLocation: function(url){ + return new Promise((resolve,reject)=>{ if (!this.isWechat()) { - uni.showToast({ - title: '不在微信客户端', - icon: 'none' + uni.showModal({ + title: '提示!', + content: '请在微信客户端内打开', + showCancel: false }) - return; + uni.hideLoading() + return + reject(res) } - //每次都需要重新初始化配置,才可以进行分享 - this.initJssdkShare(function (signData) { + //每次都需要重新初始化配置 + this.initJssdkShare(function () { jweixin.ready(function () { - var shareData = { - title: data && data.title ? data.title : signData.site_name, - desc: data && data.desc ? data.desc : signData.site_description, - link: url, - imgUrl: data && data.img ? data.img : signData.site_logo, - success: function (res) { - // 分享后的一些操作,比如分享统计等等 - }, - cancel: function (res) {} - }; - //分享给朋友接口 - jweixin.updateAppMessageShareData(shareData); - //分享到朋友圈接口 - // jweixin.updateTimelineShareData(shareData); + jweixin.getLocation({ + type: 'wgs84', + success: function (res) { + console.log('jssdk获取的位置:',res.longitude,res.latitude) + resolve(res) + }, + cancel: function (res) { + reject(res) + alert('您已禁止获取位置信息') + } + }); }); - }, url); - }, - - + },url) + }) + } } diff --git a/manifest.json b/manifest.json index 4bc6fd2..6b39934 100644 --- a/manifest.json +++ b/manifest.json @@ -25,7 +25,6 @@ "autoclose" : true, "delay" : 0 }, - /* 模块配置 */ "modules" : { "Payment" : {}, "Share" : {}, @@ -63,9 +62,7 @@ "" ] }, - /* ios打包配置 */ "ios" : {}, - /* SDK配置 */ "sdkConfigs" : { "payment" : { "weixin" : { @@ -131,9 +128,7 @@ } } }, - /* 快应用特有相关 */ "quickapp" : {}, - /* 小程序特有相关 */ "mp-weixin" : { "appid" : "wx5f5b49c361569a10", "setting" : { @@ -168,7 +163,7 @@ }, "h5" : { "title" : "番茄饭团用户端", - "domain" : "https://fanqie.h5.cyjyyjy.com", + "domain" : "https://user.fanqiefantuan.com", "sdkConfigs" : { "maps" : { "qqmap" : { @@ -177,10 +172,17 @@ } }, "router" : { - "base" : "/waimai_h5/" + "base" : "", + "mode" : "history" }, "devServer" : { - "https" : false + "https" : false, + "disableHostCheck" : true + }, + "optimization" : { + "treeShaking" : { + "enable" : true + } } } } diff --git a/pages/index/index.vue b/pages/index/index.vue index 476d287..7ba5594 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -623,7 +623,6 @@ type: 'gcj02', altitude: true, success: res => { - console.log(res, 'aaaa') // #ifdef H5 that.loAcquire(res.longitude,res.latitude) // #endif @@ -675,7 +674,6 @@ this.banners.push(d); } }); - console.log(this.banners) } }); }, @@ -887,13 +885,13 @@ width: 100%; // overflow: hidden; background-color: #F6F6F6; + } .home-bgi { width: 100%; height: 260rpx; background: #FFF; - .swiper { width: 100%; height: 100%; @@ -930,7 +928,7 @@ .nav { display: flex; align-items: center; - padding: 0 32rpx; + padding: 20rpx 32rpx 0; } .nav .citys { diff --git a/pages/index/selectCampus.vue b/pages/index/selectCampus.vue index 7f7c65f..757fb86 100644 --- a/pages/index/selectCampus.vue +++ b/pages/index/selectCampus.vue @@ -80,7 +80,7 @@ }, methods: { gocity() { - const key = 'YXDBZ-P5LWW-375RH-OCVNQ-B2HY7-U6FBG'; // 使用在腾讯位置服务申请的key + const key = 'ILKBZ-MOUWU-4Z6VM-22BLP-CUDXQ-I4F5L'; // 使用在腾讯位置服务申请的key const referer = '番茄饭团霸王餐'; // 调用插件的app的名称 const hotCitys = ''; // 用户自定义的的热门城市 wx.navigateTo({ diff --git a/pages/index/tasksdetails.vue b/pages/index/tasksdetails.vue index e49c85c..2cf4996 100644 --- a/pages/index/tasksdetails.vue +++ b/pages/index/tasksdetails.vue @@ -541,10 +541,14 @@ this.$queue.showLoading('抢单中...'); let userId = this.$queue.getData('userId'); this.$Request.postT('/wm/insertOrders?goodsId=' + this.goodsId + '&userId=' + userId).then(res => { + console.log(res) if (res.code == 0) { - this.$queue.showToast('抢单成功!'); - this.initHelpOrder(this.goodsId); + // this.$queue.showToast('抢单成功!'); + uni.showToast({ + title: '抢单成功!' + }) setTimeout(d => { + this.initHelpOrder(this.goodsId); if (this.info.classify == 2) { //美团 // #ifdef MP-WEIXIN uni.navigateToMiniProgram({ @@ -556,7 +560,7 @@ }) // #endif //#ifdef H5 - window.location.href = this.info.url; + // window.location.href = this.info.url; //#endif } else if (this.info.classify == 1) { //饿了么 // #ifdef MP-WEIXIN @@ -569,10 +573,10 @@ }) // #endif //#ifdef H5 - window.location.href = this.info.url; + // window.location.href = this.info.url; //#endif } - }, 500); + }, 1500); } else { uni.hideLoading(); this.$queue.showToast(res.msg); diff --git a/pages/my/myVIP.vue b/pages/my/myVIP.vue index 905f274..072418a 100644 --- a/pages/my/myVIP.vue +++ b/pages/my/myVIP.vue @@ -56,6 +56,7 @@ color: #FFFFFF;">元 @@ -174,6 +191,9 @@ color: #FFFFFF;">元 page { width: 100%; background-color: #FFFFFF; + /* #ifdef H5 */ + padding-top: 20rpx; + /* #endif */ } .top-box{ padding: 0 32rpx; diff --git a/pages/order/release.vue b/pages/order/release.vue index 0ea83bd..1a74c5e 100644 --- a/pages/order/release.vue +++ b/pages/order/release.vue @@ -50,8 +50,8 @@ phone: '', money: "", imageList: [], - imageList1: ['https://h5.canmoujiang.com/img/20210531/dceedf8061294b1d99043ca78ff57090.png', - 'https://h5.canmoujiang.com/img/20210531/3ff0fa04f1cb4debb6ec017293bf6c6f.jpg' + imageList1: ['https://download.cyjyyjy.com/e3975ab59055a9e453563ff9f3c6356.jpg', + 'https://download.cyjyyjy.com/f0ca8f2c95df8a516da37d83d90314d.jpg' ], orderId: '', //修改是用到的ID value1: 0, diff --git a/pages/public/login.vue b/pages/public/login.vue index 332e394..911c8a4 100644 --- a/pages/public/login.vue +++ b/pages/public/login.vue @@ -294,6 +294,8 @@ toLogin() { this.$queue.loginClear(); let openid = this.$queue.getData('openid'); + const wxCode = this.$queue.getData('wxCode'); + console.log(wxCode) const { mobilePhone, code, @@ -315,6 +317,7 @@ this.$Request .postJson('/appLogin/loginByPhone', { code: code, + wxCode: wxCode, mobile: mobilePhone }) .then(res => { diff --git a/pagesB/pages/my/myVIP.vue b/pagesB/pages/my/myVIP.vue index 001d35b..3996c42 100644 --- a/pagesB/pages/my/myVIP.vue +++ b/pagesB/pages/my/myVIP.vue @@ -180,7 +180,7 @@ color: #FFFFFF;">元 uni.showLoading({ title: '支付中' }); - this.$Request.postT('/api/order/wxPayMember?userId=' + userId).then(res => { + this.$Request.postT('/api/order/wxPayMember?userId=' + userId + '&type=3').then(res => { uni.requestPayment({ provider: 'wxpay', timeStamp: res.timestamp, diff --git a/project.config.json b/project.config.json index 155fc1a..efb8e6d 100644 --- a/project.config.json +++ b/project.config.json @@ -30,12 +30,8 @@ "enableEngineNative": false, "packNpmRelationList": [], "minifyWXSS": true, -<<<<<<< HEAD - "showES6CompileOption": false -======= "showES6CompileOption": false, "minifyWXML": true ->>>>>>> 661ea8f1c91af482df1a982bf8c644694bee7897 }, "compileType": "miniprogram", "libVersion": "2.20.1",