Browse Source

番茄h5

yh
杨豪 3 years ago
parent
commit
68153870e6
  1. 35
      App.vue
  2. 6
      common/config.js
  3. 2
      common/httpRequest.js
  4. 205
      common/jweixin.js
  5. 18
      manifest.json
  6. 6
      pages/index/index.vue
  7. 2
      pages/index/selectCampus.vue
  8. 14
      pages/index/tasksdetails.vue
  9. 64
      pages/my/myVIP.vue
  10. 4
      pages/order/release.vue
  11. 3
      pages/public/login.vue
  12. 2
      pagesB/pages/my/myVIP.vue
  13. 4
      project.config.json

35
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){ //h5code
let code = e.query.code
this.$queue.setData('wxCode', code);
}
},
onHide: function() {}
};
@ -68,4 +72,5 @@
view{
box-sizing: border-box;
}
</style>

6
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,

2
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) {

205
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)
})
}
}

18
manifest.json

@ -25,7 +25,6 @@
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {
"Payment" : {},
"Share" : {},
@ -63,9 +62,7 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* 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
}
}
}
}

6
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 {

2
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({

14
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);

64
pages/my/myVIP.vue

@ -56,6 +56,7 @@ color: #FFFFFF;">元</view>
</template>
<script>
import jweixin from '@/common/jweixin.js'
export default {
data() {
return {
@ -139,33 +140,49 @@ color: #FFFFFF;">元</view>
uni.showLoading({
title: '支付中'
});
this.$Request.postT('/api/order/wxPayMember?userId=' + userId).then(res => {
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.timestamp,
nonceStr: res.noncestr,
package: res.package,
signType: res.signType,
paySign: res.sign,
success: function(res) {
uni.showLoading({
title: '支付成功'
});
uni.hideLoading();
setTimeout(() => {
uni.navigateBack();
}, 1000);
},
fail: function(err) {
uni.hideLoading();
that.$queue.showToast('支付失败');
}
});
//#ifdef MP-WEIXIN
this.$Request.postT('/api/order/wxPayMember?userId=' + userId + '&type=3').then(res => {
this.wxPay(res)
uni.hideLoading();
})
//#endif
//#ifdef H5
this.h5Pay()
//#endif
} else {
uni.hideLoading();
this.goLogin();
}
},
wxPay(res){
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.timestamp,
nonceStr: res.noncestr,
package: res.package,
signType: res.signType,
paySign: res.sign,
success: function(res) {
uni.showLoading({
title: '支付成功'
});
uni.hideLoading();
setTimeout(() => {
uni.navigateBack();
}, 1000);
},
fail: function(err) {
uni.hideLoading();
that.$queue.showToast('支付失败');
}
});
},
h5Pay(){
var pageUrl = encodeURIComponent(window.location.href);
jweixin.wxChatWebPay(pageUrl).then((result)=>{
uni.hideLoading();
})
},
}
}
</script>
@ -174,6 +191,9 @@ color: #FFFFFF;">元</view>
page {
width: 100%;
background-color: #FFFFFF;
/* #ifdef H5 */
padding-top: 20rpx;
/* #endif */
}
.top-box{
padding: 0 32rpx;

4
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,

3
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 => {

2
pagesB/pages/my/myVIP.vue

@ -180,7 +180,7 @@ color: #FFFFFF;">元</view>
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,

4
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",

Loading…
Cancel
Save