发布通告功能
This commit is contained in:
parent
2f03910ae4
commit
76e780612e
@ -1,9 +1,9 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 微信登录授权获取code
|
// 微信登录授权获取code
|
||||||
export function getCodeUrl(userType) {
|
export function getCodeUrl(userType, url) {
|
||||||
return request({
|
return request({
|
||||||
'url': '/wxApi/getCodeUrl?userType=' + userType,
|
'url': '/wxApi/getCodeUrl?userType=' + userType + '&url=' + url,
|
||||||
'method': 'get'
|
'method': 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,16 @@
|
|||||||
<text>¥</text>{{item.price}}
|
<text>¥</text>{{item.price}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 购买 -->
|
||||||
|
<!-- #ifdef H5 -->
|
||||||
<view class="button-dom" @click="toOrder()">购买</view>
|
<view class="button-dom" @click="toOrder()">购买</view>
|
||||||
|
<!-- #endif -->
|
||||||
|
<!-- 调整h5 -->
|
||||||
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
|
<view class="button-dom" @click="openVip()">购买</view>
|
||||||
|
|
||||||
|
<!-- #endif -->
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="item-field" style="align-items: center;">
|
<view class="item-field" style="align-items: center;">
|
||||||
<view class="my-suggest-dom" @click="viewRichText()">
|
<view class="my-suggest-dom" @click="viewRichText()">
|
||||||
@ -39,7 +48,8 @@
|
|||||||
<view class="item-box" v-for="(item,index) in byList">
|
<view class="item-box" v-for="(item,index) in byList">
|
||||||
<view class="top-title-box">
|
<view class="top-title-box">
|
||||||
<view class="order-no">订单编号:{{item.orderNo}}</view>
|
<view class="order-no">订单编号:{{item.orderNo}}</view>
|
||||||
<view :class="['order-status',item.isPay==1?'payed':'no-pay']">{{item.isPay==1?'已支付':'未支付'}}
|
<view :class="['order-status',item.isPay==1?'payed':'no-pay']">
|
||||||
|
{{item.isPay==1?'已支付':'未支付'}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="detail-item">
|
<view class="detail-item">
|
||||||
@ -66,11 +76,28 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import navigationBarVue from '@/components/navigation/navigationBar.vue';
|
import navigationBarVue from '@/components/navigation/navigationBar.vue';
|
||||||
import {initCouponList} from '@/api/business/base.js'
|
import {
|
||||||
import {saveOrder,getOrderList} from '@/api/business/member.js'
|
initCouponList
|
||||||
import {toast} from '@/utils/common.js'
|
} from '@/api/business/base.js'
|
||||||
|
import {
|
||||||
|
saveOrder,
|
||||||
|
getOrderList
|
||||||
|
} from '@/api/business/member.js'
|
||||||
|
import {
|
||||||
|
toast
|
||||||
|
} from '@/utils/common.js'
|
||||||
import constant from '@/utils/constant';
|
import constant from '@/utils/constant';
|
||||||
import {getJSONData} from '@/utils/auth.js'
|
import {
|
||||||
|
getJSONData
|
||||||
|
} from '@/utils/auth.js'
|
||||||
|
import {
|
||||||
|
getCodeUrl,
|
||||||
|
getWebAccessTokenAndOpenid,
|
||||||
|
gzhLogin
|
||||||
|
} from '@/api/wxApi'
|
||||||
|
import {
|
||||||
|
getToken
|
||||||
|
} from '@/utils/auth'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
navigationBarVue
|
navigationBarVue
|
||||||
@ -80,14 +107,14 @@
|
|||||||
globalConfig: getApp().globalData.config,
|
globalConfig: getApp().globalData.config,
|
||||||
menus: ['通告券', '购买记录'],
|
menus: ['通告券', '购买记录'],
|
||||||
menuIndex: 0,
|
menuIndex: 0,
|
||||||
coupon:0,
|
coupon: 0,
|
||||||
//选中的通告券下标
|
//选中的通告券下标
|
||||||
couponIndex: 0,
|
couponIndex: 0,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
orderType:'02',
|
orderType: '02',
|
||||||
userId:null,
|
userId: null,
|
||||||
},
|
},
|
||||||
total: 0,
|
total: 0,
|
||||||
//下来刷新状态
|
//下来刷新状态
|
||||||
@ -98,12 +125,76 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
this.menuIndex = option.index
|
this.menuIndex = option.index || 0
|
||||||
this.coupon = option.coupon
|
this.coupon = option.coupon || 0
|
||||||
this.initCoupon();
|
this.initCoupon();
|
||||||
this.initOrder()
|
this.initOrder()
|
||||||
|
//获取url中的search
|
||||||
|
if (location.search) {
|
||||||
|
let search = location.search.slice(1);
|
||||||
|
let arr = search.split("&");
|
||||||
|
let result = {};
|
||||||
|
arr.forEach(function(item) {
|
||||||
|
let itemArr = item.split('=');
|
||||||
|
result[itemArr[0]] = itemArr[1];
|
||||||
|
})
|
||||||
|
if (result.code) {
|
||||||
|
let that = this
|
||||||
|
getWebAccessTokenAndOpenid(result.code).then(res => {
|
||||||
|
that.$store.dispatch('GzhLogin', res).then(() => {
|
||||||
|
this.initCoupon();
|
||||||
|
this.initOrder()
|
||||||
|
that.loginSuccess()
|
||||||
|
}).catch((e) => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
title: e
|
||||||
|
});
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.toLogin()
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
openVip() {
|
||||||
|
// 在你想触发跳转的地方
|
||||||
|
wx.openOfficialAccountProfile({
|
||||||
|
username: 'tonggaokuaijie', // 此处填写公众号的微信号
|
||||||
|
success: res => {},
|
||||||
|
fail: res => {}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
// 登录成功后,处理函数
|
||||||
|
loginSuccess(result) {
|
||||||
|
// 设置用户信息
|
||||||
|
this.$store.dispatch('GetInfo').then(res => {
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toLogin() {
|
||||||
|
/*#ifdef APP-PLUS*/
|
||||||
|
// App端特有的逻辑
|
||||||
|
console.log('Running on App-Plus');
|
||||||
|
/*#endif*/
|
||||||
|
/*#ifdef H5*/
|
||||||
|
// 在浏览器端(H5)执行的逻辑
|
||||||
|
if (!getToken()) {
|
||||||
|
//未登录状态
|
||||||
|
getCodeUrl("01", "pages/mine/coupon/my-coupon").then(res => {
|
||||||
|
window.location.href = res.codeUrl;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/*#endif*/
|
||||||
|
/*#ifdef MP-WEIXIN*/
|
||||||
|
// 微信小程序端执行的逻辑
|
||||||
|
console.log('Running on WeChat Mini Program');
|
||||||
|
/*#endif*/
|
||||||
|
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 菜单点击
|
* 菜单点击
|
||||||
* @param {Object} index
|
* @param {Object} index
|
||||||
@ -115,17 +206,21 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**查询卡券*/
|
/**查询卡券*/
|
||||||
initCoupon(){
|
initCoupon() {
|
||||||
|
if (getToken()) {
|
||||||
this.dataList = []
|
this.dataList = []
|
||||||
initCouponList().then(res=>{
|
initCouponList().then(res => {
|
||||||
this.dataList = res.data
|
this.dataList = res.data
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**初始化订单数据*/
|
/**初始化订单数据*/
|
||||||
initOrder(){
|
initOrder() {
|
||||||
|
if (getToken()) {
|
||||||
this.queryParams.userId = getJSONData(constant.userInfo).userId
|
this.queryParams.userId = getJSONData(constant.userInfo).userId
|
||||||
getOrderList(this.queryParams).then(res=>{
|
getOrderList(this.queryParams).then(res => {
|
||||||
this.isTriggered = false
|
this.isTriggered = false
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
if (this.queryParams.pageNum == 1) {
|
if (this.queryParams.pageNum == 1) {
|
||||||
@ -136,26 +231,28 @@
|
|||||||
this.total = res.data.total
|
this.total = res.data.total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**生成订单*/
|
/**生成订单*/
|
||||||
toOrder(){
|
async toOrder() {
|
||||||
let data = {
|
let data = {
|
||||||
userType:'01',
|
userType: '01',
|
||||||
orderType:'02',
|
orderType: '02',
|
||||||
goodsId:this.dataList[this.couponIndex].id,
|
goodsId: this.dataList[this.couponIndex].id,
|
||||||
goodsNum:this.dataList[this.couponIndex].couponNum,
|
goodsNum: this.dataList[this.couponIndex].couponNum,
|
||||||
goodsPrice:this.dataList[this.couponIndex].price,
|
goodsPrice: this.dataList[this.couponIndex].price,
|
||||||
goodsCycle:'04'
|
goodsCycle: '04'
|
||||||
}
|
}
|
||||||
saveOrder(data).then(res => {
|
saveOrder(data).then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
uni.showToast({
|
//吊起支付
|
||||||
icon: 'success',
|
let payData = {
|
||||||
duration: 2000,
|
orderNo: res.data.orderNo
|
||||||
title: '保存成功'
|
}
|
||||||
});
|
prepayment(payData).then(paymentData => {
|
||||||
uni.navigateBack()
|
that.wxpay(paymentData)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -204,6 +301,56 @@
|
|||||||
this.total = 0
|
this.total = 0
|
||||||
this.initOrder()
|
this.initOrder()
|
||||||
},
|
},
|
||||||
|
// 检测支付环境中的 WeixinJSBridge
|
||||||
|
wxpay(data) {
|
||||||
|
if (typeof WeixinJSBridge == "undefined") {
|
||||||
|
if (document.addEventListener) {
|
||||||
|
document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false);
|
||||||
|
} else if (document.attachEvent) {
|
||||||
|
document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data));
|
||||||
|
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.onBridgeReady(data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onBridgeReady(data) {
|
||||||
|
|
||||||
|
WeixinJSBridge.invoke(
|
||||||
|
'getBrandWCPayRequest', {
|
||||||
|
// 传入第一步后端接口返回的核心参数
|
||||||
|
"appId": data.appId, //公众号
|
||||||
|
"timeStamp": data.timeStamp, //时间戳
|
||||||
|
"nonceStr": data.nonceStr, //随机串
|
||||||
|
"package": data.packageVal, //prepay_id
|
||||||
|
"signType": data.signType, //微信签名方式RSA
|
||||||
|
"paySign": data.paySign //微信签名
|
||||||
|
},
|
||||||
|
function(res) {
|
||||||
|
// 支付成功
|
||||||
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||||
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
||||||
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
||||||
|
}
|
||||||
|
// 支付过程中用户取消
|
||||||
|
if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
||||||
|
|
||||||
|
}
|
||||||
|
// 支付失败
|
||||||
|
if (res.err_msg == "get_brand_wcpay_request:fail") {
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 其它
|
||||||
|
* 1、请检查预支付会话标识prepay_id是否已失效
|
||||||
|
* 2、请求的appid与下单接口的appid是否一致
|
||||||
|
* */
|
||||||
|
if (res.err_msg == "调用支付JSAPI缺少参数:total_fee") {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -182,7 +182,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
let userTypeTemp = options.userType
|
||||||
|
this.initData(userTypeTemp);
|
||||||
//获取url中的search
|
//获取url中的search
|
||||||
|
if (location.search) {
|
||||||
let search = location.search.slice(1);
|
let search = location.search.slice(1);
|
||||||
let arr = search.split("&");
|
let arr = search.split("&");
|
||||||
let result = {};
|
let result = {};
|
||||||
@ -190,9 +193,6 @@
|
|||||||
let itemArr = item.split('=');
|
let itemArr = item.split('=');
|
||||||
result[itemArr[0]] = itemArr[1];
|
result[itemArr[0]] = itemArr[1];
|
||||||
})
|
})
|
||||||
let userTypeTemp = options.userType
|
|
||||||
|
|
||||||
this.initData(userTypeTemp);
|
|
||||||
if (result.code) {
|
if (result.code) {
|
||||||
userTypeTemp = result.state
|
userTypeTemp = result.state
|
||||||
let that = this
|
let that = this
|
||||||
@ -211,7 +211,7 @@
|
|||||||
} else {
|
} else {
|
||||||
this.toLogin(userTypeTemp)
|
this.toLogin(userTypeTemp)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -223,13 +223,6 @@
|
|||||||
fail: res => {}
|
fail: res => {}
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
binderror() {
|
|
||||||
|
|
||||||
},
|
|
||||||
bindload() {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// 登录成功后,处理函数
|
// 登录成功后,处理函数
|
||||||
loginSuccess(result) {
|
loginSuccess(result) {
|
||||||
@ -243,17 +236,15 @@
|
|||||||
// App端特有的逻辑
|
// App端特有的逻辑
|
||||||
console.log('Running on App-Plus');
|
console.log('Running on App-Plus');
|
||||||
/*#endif*/
|
/*#endif*/
|
||||||
|
|
||||||
/*#ifdef H5*/
|
/*#ifdef H5*/
|
||||||
// 在浏览器端(H5)执行的逻辑
|
// 在浏览器端(H5)执行的逻辑
|
||||||
if (!getToken()) {
|
if (!getToken()) {
|
||||||
//未登录状态
|
//未登录状态
|
||||||
getCodeUrl(userType).then(res => {
|
getCodeUrl(userType, "pages/mine/member/member-card").then(res => {
|
||||||
window.location.href = res.codeUrl;
|
window.location.href = res.codeUrl;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/*#endif*/
|
/*#endif*/
|
||||||
|
|
||||||
/*#ifdef MP-WEIXIN*/
|
/*#ifdef MP-WEIXIN*/
|
||||||
// 微信小程序端执行的逻辑
|
// 微信小程序端执行的逻辑
|
||||||
console.log('Running on WeChat Mini Program');
|
console.log('Running on WeChat Mini Program');
|
||||||
|
|||||||
@ -77,7 +77,7 @@
|
|||||||
<!-- 发布通告 -->
|
<!-- 发布通告 -->
|
||||||
<view class="public-notice-box" v-if="'01'==localUserType">
|
<view class="public-notice-box" v-if="'01'==localUserType">
|
||||||
<view class="left-box">
|
<view class="left-box">
|
||||||
<view style="margin-bottom: 20rpx;">发布通告额度剩余{{userInfo.coupon}}条</view>
|
<view style="margin-bottom: 20rpx;">发布通告额度剩余{{userInfo.coupon||0}}条</view>
|
||||||
<!-- <progress style="width: 90%;" border-radius="5" percent="40" activeColor="#FC1F3E"-->
|
<!-- <progress style="width: 90%;" border-radius="5" percent="40" activeColor="#FC1F3E"-->
|
||||||
<!-- backgroundColor="#DEDEDE" stroke-width="8" />-->
|
<!-- backgroundColor="#DEDEDE" stroke-width="8" />-->
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user