From b2db4296ff0d154353e09b10b920092d9801d84f Mon Sep 17 00:00:00 2001
From: 13405411873 <1994398261@qq.com>
Date: Thu, 24 Apr 2025 17:10:07 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=80=9A=E5=91=8A=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/business/member.js | 10 ++-
config.js | 5 +-
main.js | 3 +-
pages/components/notice-index.vue | 62 ++++++++------
pages/index.vue | 8 +-
pages/mine/member/member-card.vue | 130 +++++++++++++++++++++++++----
pages/notice/report.vue | 8 +-
store/modules/user.js | 19 ++++-
utils/request.js | 131 ++++++++++++++++--------------
9 files changed, 257 insertions(+), 119 deletions(-)
diff --git a/api/business/member.js b/api/business/member.js
index dd921ec..f671e65 100644
--- a/api/business/member.js
+++ b/api/business/member.js
@@ -162,6 +162,14 @@ export function getOrderList(params) {
})
}
+export function prepayment(data) {
+ return request({
+ url: '/payApi/prepayment',
+ method: 'get',
+ params: data
+ })
+}
+
export function saveOrder(data) {
return request({
url: '/member/order/uniSaveOrder',
@@ -184,4 +192,4 @@ export function saveBlack(data) {
method: 'post',
data: data
})
-}
\ No newline at end of file
+}
diff --git a/config.js b/config.js
index c7e8b7e..ebae61a 100644
--- a/config.js
+++ b/config.js
@@ -1,7 +1,8 @@
// 应用全局配置
module.exports = {
- // baseUrl: 'https://notice.lighting-it.cn',
- baseUrl: 'http://localhost:8080',
+ //baseUrl: 'https://notice.lighting-it.cn',
+ baseUrl: 'https://www.ddtg.site/noticeApi',
+ //baseUrl: 'http://192.168.1.31:8099',
// 应用信息
appInfo: {
// 应用名称
diff --git a/main.js b/main.js
index 961b30a..632ba5b 100644
--- a/main.js
+++ b/main.js
@@ -4,13 +4,12 @@ import store from './store' // store
import plugins from './plugins' // plugins
import './permission' // permission
Vue.use(plugins)
-
Vue.config.productionTip = false
Vue.prototype.$store = store
App.mpType = 'app'
const app = new Vue({
- ...App
+ ...App
})
app.$mount()
diff --git a/pages/components/notice-index.vue b/pages/components/notice-index.vue
index 24c3694..ee200a5 100644
--- a/pages/components/notice-index.vue
+++ b/pages/components/notice-index.vue
@@ -66,6 +66,9 @@
+
+
+
{
- if (res.code == 200) {
- this.$tab.navigateTo(`/pages/notice/detail?id=${item.id}`)
+ if (!userInfo) {
+ store.dispatch('LogOut').then(res => {
+ uni.reLaunch({
+ url: '/pages/login'
+ })
+ })
+ } else {
+
+ let userType = getUserType()
+ let param = {
+ userId: userInfo.userId,
+ userType: userType,
+ noticeId: item.id,
+ rightsCode: 'unlock_notice',
+ deplete: 1
}
- }).catch((e) => {
- uni.showToast({
- icon: 'error',
- duration: 2000,
- title: e
- });
- })
+ dealMemberRights(param).then(res => {
+ if (res.code == 200) {
+ this.$tab.navigateTo(`/pages/notice/detail?id=${item.id}`)
+ }
+ }).catch((e) => {
+ uni.showToast({
+ icon: 'error',
+ duration: 2000,
+ title: e
+ });
+ })
+ }
},
/**扣除解锁通告权益*/
diff --git a/pages/index.vue b/pages/index.vue
index 81df07c..b75a86e 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -121,13 +121,13 @@
* 菜单切换
* @param {Object} code
*/
- changeMenu(code) {
+ async changeMenu(code) {
this.nowUserType = getUserType()
if ("fabu" == code) {
this.$tab.navigateTo('/pages/notice/public-notice')
} else {
if (code == 'dingyue') {
- if (!this.checkIfHasRights(rightsCode.subscribeSelect)) {
+ if (!await this.checkIfHasRights(rightsCode.subscribeSelect)) {
return
}
}
@@ -141,7 +141,7 @@
async checkIfHasRights(rigthsCode) {
let res = await hasRights(rigthsCode)
if (!res) {
- toast('请开通会员')
+ this.openVip()
return false
}
return true
@@ -218,4 +218,4 @@
width: 70vw;
}
}
-
\ No newline at end of file
+
diff --git a/pages/mine/member/member-card.vue b/pages/mine/member/member-card.vue
index 646698d..e868a3a 100644
--- a/pages/mine/member/member-card.vue
+++ b/pages/mine/member/member-card.vue
@@ -28,7 +28,14 @@
+
立即开通
+
+
+
+ 立即开通
+
+
开通即代表您已阅读并同意 {
-
- gzhLogin(res)
+ that.$store.dispatch('GzhLogin', res).then(() => {
+ that.initData(userTypeTemp);
+ that.loginSuccess()
+ }).catch((e) => {
+ uni.showToast({
+ icon: 'error',
+ duration: 2000,
+ title: e
+ });
+ })
})
} else {
- this.toLogin(options.userType)
+ this.toLogin(userTypeTemp)
}
},
methods: {
+ openVip() {
+ // 在你想触发跳转的地方
+ wx.openOfficialAccountProfile({
+ username: 'tonggaokuaijie', // 此处填写公众号的微信号
+ success: res => {},
+ fail: res => {}
+ })
+
+ },
+
+ binderror() {
+
+ },
+ bindload() {
+
+ },
+ // 登录成功后,处理函数
+ loginSuccess(result) {
+ // 设置用户信息
+ this.$store.dispatch('GetInfo').then(res => {
+
+ })
+ },
toLogin(userType) {
/*#ifdef APP-PLUS*/
// App端特有的逻辑
@@ -223,7 +262,8 @@
},
/**初始化*/
initData(userType) {
- if (getToken()) {
+
+ if (getToken() && userType) {
this.userType = userType
this.getCardList(userType);
this.getRightsList(userType);
@@ -283,9 +323,12 @@
// 查看相关协议
handleUserAgrement(site) {
this.$tab.navigateTo(`/pages/common/richview/index?title=${site.title}&code=${site.code}`)
+ },
+ toOpenH5() {
+
},
/**生成订单*/
- toOrder() {
+ async toOrder() {
let data = {
userType: this.userType,
orderType: '01',
@@ -302,14 +345,17 @@
if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '月付会员') {
data.goodsCycle = '01'
}
+ let that = this
saveOrder(data).then(res => {
if (res.code == 200) {
- uni.showToast({
- icon: 'success',
- duration: 2000,
- title: '保存成功'
- });
- uni.navigateBack()
+ //吊起支付
+ let payData = {
+ orderNo: res.data.orderNo
+ }
+ prepayment(payData).then(paymentData => {
+ that.wxpay(paymentData)
+ })
+ // uni.navigateBack()
}
}).catch((e) => {
uni.showToast({
@@ -319,6 +365,58 @@
});
})
},
+ // 检测支付环境中的 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") {
+
+ }
+ });
+ }
+
+
}
}
diff --git a/pages/notice/report.vue b/pages/notice/report.vue
index 334aca8..224eedf 100644
--- a/pages/notice/report.vue
+++ b/pages/notice/report.vue
@@ -258,8 +258,8 @@
formatNumberWithUnits(number) {
return formatNumberWithUnits(number)
},
- getRightsCode() {
- let info = hasRights(rightsCode.manyCardReport)
+ async getRightsCode() {
+ let info = await hasRights(rightsCode.manyCardReport)
if (!info) {
this.rightInfo.manyCardReport = false
} else {
@@ -319,9 +319,9 @@
});
})
},
- submit(isSuper) {
+ async submit(isSuper) {
if (isSuper == '1') {
- let flag = hasRights(rightsCode.superReport)
+ let flag = await hasRights(rightsCode.superReport)
if (!flag) {
uni.showToast({
title: '无超级报名权益',
diff --git a/store/modules/user.js b/store/modules/user.js
index 364093c..42ae65f 100644
--- a/store/modules/user.js
+++ b/store/modules/user.js
@@ -4,6 +4,9 @@ import constant from '@/utils/constant'
import {
changeUserType
} from '@/utils/common.js'
+import {
+ gzhLogin
+} from '@/api/wxApi'
import {
login,
wxLogin,
@@ -69,6 +72,20 @@ const user = {
})
})
},
+ // 公众号登录
+ GzhLogin({
+ commit
+ }, data) {
+ return new Promise((resolve, reject) => {
+ gzhLogin(data).then(res => {
+ setToken(res.token)
+ commit('SET_TOKEN', res.token)
+ resolve()
+ }).catch(error => {
+ reject(error)
+ })
+ })
+ },
// 登录
Login({
commit
@@ -144,4 +161,4 @@ const user = {
}
}
-export default user
\ No newline at end of file
+export default user
diff --git a/utils/request.js b/utils/request.js
index 110816d..248de8b 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -1,73 +1,78 @@
import store from '@/store'
import config from '@/config'
-import { getToken } from '@/utils/auth'
+import {
+ getToken
+} from '@/utils/auth'
import errorCode from '@/utils/errorCode'
-import { toast, showConfirm, tansParams } from '@/utils/common'
+import {
+ toast,
+ showConfirm,
+ tansParams
+} from '@/utils/common'
let timeout = 10000
const baseUrl = config.baseUrl
const request = config => {
- // 是否需要设置 token
- const isToken = (config.headers || {}).isToken === false
- config.header = config.header || {}
- if (getToken() && !isToken) {
- config.header['Authorization'] = 'Bearer ' + getToken()
- }
- // get请求映射params参数
- if (config.params) {
- let url = config.url + '?' + tansParams(config.params)
- url = url.slice(0, -1)
- config.url = url
- }
- return new Promise((resolve, reject) => {
- uni.request({
- method: config.method || 'get',
- timeout: config.timeout || timeout,
- url: config.baseUrl || baseUrl + config.url,
- data: config.data,
- header: config.header,
- dataType: 'json'
- }).then(response => {
- let [error, res] = response
- if (error) {
- toast('后端接口连接异常')
- reject('后端接口连接异常')
- return
- }
- const code = res.data.code || 200
- const msg = errorCode[code] || res.data.msg || errorCode['default']
- if (code === 401) {
- showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
- if (res.confirm) {
- store.dispatch('LogOut').then(res => {
- uni.reLaunch({ url: '/pages/login' })
- })
- }
- })
- reject('无效的会话,或者会话已过期,请重新登录。')
- } else if (code === 500) {
- toast(msg)
- reject(msg)
- } else if (code !== 200) {
- toast(msg)
- reject(msg)
- }
- resolve(res.data)
- })
- .catch(error => {
- let { message } = error
- if (message === 'Network Error') {
- message = '后端接口连接异常'
- } else if (message.includes('timeout')) {
- message = '系统接口请求超时'
- } else if (message.includes('Request failed with status code')) {
- message = '系统接口' + message.substr(message.length - 3) + '异常'
- }
- toast(message)
- reject(error)
- })
- })
+ // 是否需要设置 token
+ const isToken = (config.headers || {}).isToken === false
+ config.header = config.header || {}
+ if (getToken() && !isToken) {
+ config.header['Authorization'] = 'Bearer ' + getToken()
+ }
+ // get请求映射params参数
+ if (config.params) {
+ let url = config.url + '?' + tansParams(config.params)
+ url = url.slice(0, -1)
+ config.url = url
+ }
+ return new Promise((resolve, reject) => {
+ uni.request({
+ method: config.method || 'get',
+ timeout: config.timeout || timeout,
+ url: config.baseUrl || baseUrl + config.url,
+ data: config.data,
+ header: config.header,
+ dataType: 'json'
+ }).then(response => {
+ let [error, res] = response
+ if (error) {
+ toast('后端接口连接异常')
+ reject('后端接口连接异常')
+ return
+ }
+ const code = res.data.code || 200
+ const msg = errorCode[code] || res.data.msg || errorCode['default']
+ if (code === 401) {
+ store.dispatch('LogOut').then(res => {
+ uni.reLaunch({
+ url: '/pages/login'
+ })
+ })
+ } else if (code === 500) {
+ toast(msg)
+ reject(msg)
+ } else if (code !== 200) {
+ toast(msg)
+ reject(msg)
+ }
+ resolve(res.data)
+ })
+ .catch(error => {
+ let {
+ message
+ } = error
+ if (message === 'Network Error') {
+ message = '后端接口连接异常'
+ } else if (message.includes('timeout')) {
+ message = '系统接口请求超时'
+ } else if (message.includes('Request failed with status code')) {
+ message = '系统接口' + message.substr(message.length - 3) + '异常'
+ }
+ toast(message)
+ reject(error)
+ })
+ })
}
-export default request
+export default request
\ No newline at end of file