发布通告功能

This commit is contained in:
13405411873 2025-04-24 17:10:07 +08:00
parent dc5652983a
commit b2db4296ff
9 changed files with 257 additions and 119 deletions

View File

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

View File

@ -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: {
// 应用名称

View File

@ -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()

View File

@ -66,6 +66,9 @@
<image class="dl-go-view" src="@/static/index/go-view.png" mode="aspectFit"></image>
</view>
</view>
<!-- 通告列表 -->
<view class="dl-item-box">
<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="onReachBottomCus" refresher-enabled
@ -181,6 +184,7 @@
getUserType
} from '@/utils/common.js'
import constant from '@/utils/constant';
import store from '@/store'
export default {
components: {
@ -292,12 +296,9 @@
* 选择平台
*/
async choosePlat(index) {
this.$emit("openVip")
return
if (index == 2) {
//
if (!this.checkIfHasRights(rightsCode.subscribeSelect)) {
this.$emit("openVip")
if (!await this.checkIfHasRights(rightsCode.subscribeSelect)) {
return
}
this.$refs.showRight2.open()
@ -349,13 +350,13 @@
} else if ('最新' == item) {
//
//
if (!this.checkIfHasRights(rightsCode.highNewNotice)) {
if (!await this.checkIfHasRights(rightsCode.highNewNotice)) {
return
}
this.queryParams.sortBy = "new"
} else if ('高奖励' == item) {
//
if (!this.checkIfHasRights(rightsCode.highNewNotice)) {
if (!await this.checkIfHasRights(rightsCode.highNewNotice)) {
return
}
this.queryParams.sortBy = "money"
@ -371,7 +372,7 @@
*/
async goSeach() {
//
if (!this.checkIfHasRights(rightsCode.searchNotice)) {
if (!await this.checkIfHasRights(rightsCode.searchNotice)) {
return
}
this.showSearch = true
@ -383,7 +384,7 @@
async checkIfHasRights(rigthsCode) {
let res = await hasRights(rigthsCode)
if (!res) {
toast('请开通会员')
this.$emit("openVip")
return false
}
return true
@ -455,25 +456,34 @@
*/
goDetail(item) {
let userInfo = getJSONData(constant.userInfo)
let userType = getUserType()
let param = {
userId: userInfo.userId,
userType: userType,
noticeId: item.id,
rightsCode: 'unlock_notice',
deplete: 1
}
dealMemberRights(param).then(res => {
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
});
})
}
},
/**扣除解锁通告权益*/

View File

@ -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;
}
}
</style>
</style>

View File

@ -28,7 +28,14 @@
</view>
</view>
<!-- 购买 -->
<!-- #ifdef H5 -->
<view class="buy-button" @click="toOrder()">立即开通</view>
<!-- #endif -->
<!-- 调整h5 -->
<!-- #ifdef MP-WEIXIN -->
<view class="buy-button" @click="openVip()">立即开通</view>
<!-- #endif -->
<!-- 协议 -->
<view class="xieyi-box">
开通即代表您已阅读并同意<text
@ -74,7 +81,8 @@
rightList
} from '@/api/business/base.js'
import {
saveOrder
saveOrder,
prepayment
} from '@/api/business/member.js'
import {
getToken
@ -174,31 +182,62 @@
},
onLoad(options) {
this.initData(options.userType);
//urlsearch
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];
})
let userTypeTemp = options.userType
this.initData(userTypeTemp);
if (result.code) {
userTypeTemp = result.state
let that = this
getWebAccessTokenAndOpenid(result.code).then(res => {
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_msgok
}
//
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>

View File

@ -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: '无超级报名权益',

View File

@ -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
export default user

View File

@ -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