发布通告功能

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) { export function saveOrder(data) {
return request({ return request({
url: '/member/order/uniSaveOrder', url: '/member/order/uniSaveOrder',
@ -184,4 +192,4 @@ export function saveBlack(data) {
method: 'post', method: 'post',
data: data data: data
}) })
} }

View File

@ -1,7 +1,8 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
// baseUrl: 'https://notice.lighting-it.cn', //baseUrl: 'https://notice.lighting-it.cn',
baseUrl: 'http://localhost:8080', baseUrl: 'https://www.ddtg.site/noticeApi',
//baseUrl: 'http://192.168.1.31:8099',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@ -4,13 +4,12 @@ import store from './store' // store
import plugins from './plugins' // plugins import plugins from './plugins' // plugins
import './permission' // permission import './permission' // permission
Vue.use(plugins) Vue.use(plugins)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$store = store Vue.prototype.$store = store
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App ...App
}) })
app.$mount() app.$mount()

View File

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

View File

@ -121,13 +121,13 @@
* 菜单切换 * 菜单切换
* @param {Object} code * @param {Object} code
*/ */
changeMenu(code) { async changeMenu(code) {
this.nowUserType = getUserType() this.nowUserType = getUserType()
if ("fabu" == code) { if ("fabu" == code) {
this.$tab.navigateTo('/pages/notice/public-notice') this.$tab.navigateTo('/pages/notice/public-notice')
} else { } else {
if (code == 'dingyue') { if (code == 'dingyue') {
if (!this.checkIfHasRights(rightsCode.subscribeSelect)) { if (!await this.checkIfHasRights(rightsCode.subscribeSelect)) {
return return
} }
} }
@ -141,7 +141,7 @@
async checkIfHasRights(rigthsCode) { async checkIfHasRights(rigthsCode) {
let res = await hasRights(rigthsCode) let res = await hasRights(rigthsCode)
if (!res) { if (!res) {
toast('请开通会员') this.openVip()
return false return false
} }
return true return true
@ -218,4 +218,4 @@
width: 70vw; width: 70vw;
} }
} }
</style> </style>

View File

@ -28,7 +28,14 @@
</view> </view>
</view> </view>
<!-- 购买 --> <!-- 购买 -->
<!-- #ifdef H5 -->
<view class="buy-button" @click="toOrder()">立即开通</view> <view class="buy-button" @click="toOrder()">立即开通</view>
<!-- #endif -->
<!-- 调整h5 -->
<!-- #ifdef MP-WEIXIN -->
<view class="buy-button" @click="openVip()">立即开通</view>
<!-- #endif -->
<!-- 协议 --> <!-- 协议 -->
<view class="xieyi-box"> <view class="xieyi-box">
开通即代表您已阅读并同意<text 开通即代表您已阅读并同意<text
@ -74,7 +81,8 @@
rightList rightList
} from '@/api/business/base.js' } from '@/api/business/base.js'
import { import {
saveOrder saveOrder,
prepayment
} from '@/api/business/member.js' } from '@/api/business/member.js'
import { import {
getToken getToken
@ -174,31 +182,62 @@
}, },
onLoad(options) { onLoad(options) {
this.initData(options.userType);
//urlsearch //urlsearch
let search = location.search.slice(1); let search = location.search.slice(1);
let arr = search.split("&"); let arr = search.split("&");
let result = {}; let result = {};
arr.forEach(function(item) { arr.forEach(function(item) {
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
let that = this
getWebAccessTokenAndOpenid(result.code).then(res => { getWebAccessTokenAndOpenid(result.code).then(res => {
that.$store.dispatch('GzhLogin', res).then(() => {
gzhLogin(res) that.initData(userTypeTemp);
that.loginSuccess()
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
}) })
} else { } else {
this.toLogin(options.userType) this.toLogin(userTypeTemp)
} }
}, },
methods: { methods: {
openVip() {
//
wx.openOfficialAccountProfile({
username: 'tonggaokuaijie', //
success: res => {},
fail: res => {}
})
},
binderror() {
},
bindload() {
},
//
loginSuccess(result) {
//
this.$store.dispatch('GetInfo').then(res => {
})
},
toLogin(userType) { toLogin(userType) {
/*#ifdef APP-PLUS*/ /*#ifdef APP-PLUS*/
// App // App
@ -223,7 +262,8 @@
}, },
/**初始化*/ /**初始化*/
initData(userType) { initData(userType) {
if (getToken()) {
if (getToken() && userType) {
this.userType = userType this.userType = userType
this.getCardList(userType); this.getCardList(userType);
this.getRightsList(userType); this.getRightsList(userType);
@ -283,9 +323,12 @@
// //
handleUserAgrement(site) { handleUserAgrement(site) {
this.$tab.navigateTo(`/pages/common/richview/index?title=${site.title}&code=${site.code}`) this.$tab.navigateTo(`/pages/common/richview/index?title=${site.title}&code=${site.code}`)
},
toOpenH5() {
}, },
/**生成订单*/ /**生成订单*/
toOrder() { async toOrder() {
let data = { let data = {
userType: this.userType, userType: this.userType,
orderType: '01', orderType: '01',
@ -302,14 +345,17 @@
if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '月付会员') { if (this.memberCardList[this.chooseCardIndex].priceList[this.choosePriceIndex].title === '月付会员') {
data.goodsCycle = '01' data.goodsCycle = '01'
} }
let that = this
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)
})
// uni.navigateBack()
} }
}).catch((e) => { }).catch((e) => {
uni.showToast({ 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> </script>

View File

@ -258,8 +258,8 @@
formatNumberWithUnits(number) { formatNumberWithUnits(number) {
return formatNumberWithUnits(number) return formatNumberWithUnits(number)
}, },
getRightsCode() { async getRightsCode() {
let info = hasRights(rightsCode.manyCardReport) let info = await hasRights(rightsCode.manyCardReport)
if (!info) { if (!info) {
this.rightInfo.manyCardReport = false this.rightInfo.manyCardReport = false
} else { } else {
@ -319,9 +319,9 @@
}); });
}) })
}, },
submit(isSuper) { async submit(isSuper) {
if (isSuper == '1') { if (isSuper == '1') {
let flag = hasRights(rightsCode.superReport) let flag = await hasRights(rightsCode.superReport)
if (!flag) { if (!flag) {
uni.showToast({ uni.showToast({
title: '无超级报名权益', title: '无超级报名权益',

View File

@ -4,6 +4,9 @@ import constant from '@/utils/constant'
import { import {
changeUserType changeUserType
} from '@/utils/common.js' } from '@/utils/common.js'
import {
gzhLogin
} from '@/api/wxApi'
import { import {
login, login,
wxLogin, 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({ Login({
commit commit
@ -144,4 +161,4 @@ const user = {
} }
} }
export default user export default user

View File

@ -1,73 +1,78 @@
import store from '@/store' import store from '@/store'
import config from '@/config' import config from '@/config'
import { getToken } from '@/utils/auth' import {
getToken
} from '@/utils/auth'
import errorCode from '@/utils/errorCode' import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common' import {
toast,
showConfirm,
tansParams
} from '@/utils/common'
let timeout = 10000 let timeout = 10000
const baseUrl = config.baseUrl const baseUrl = config.baseUrl
const request = config => { const request = config => {
// 是否需要设置 token // 是否需要设置 token
const isToken = (config.headers || {}).isToken === false const isToken = (config.headers || {}).isToken === false
config.header = config.header || {} config.header = config.header || {}
if (getToken() && !isToken) { if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken() config.header['Authorization'] = 'Bearer ' + getToken()
} }
// get请求映射params参数 // get请求映射params参数
if (config.params) { if (config.params) {
let url = config.url + '?' + tansParams(config.params) let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1) url = url.slice(0, -1)
config.url = url config.url = url
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
method: config.method || 'get', method: config.method || 'get',
timeout: config.timeout || timeout, timeout: config.timeout || timeout,
url: config.baseUrl || baseUrl + config.url, url: config.baseUrl || baseUrl + config.url,
data: config.data, data: config.data,
header: config.header, header: config.header,
dataType: 'json' dataType: 'json'
}).then(response => { }).then(response => {
let [error, res] = response let [error, res] = response
if (error) { if (error) {
toast('后端接口连接异常') toast('后端接口连接异常')
reject('后端接口连接异常') reject('后端接口连接异常')
return return
} }
const code = res.data.code || 200 const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default'] const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) { if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => { store.dispatch('LogOut').then(res => {
if (res.confirm) { uni.reLaunch({
store.dispatch('LogOut').then(res => { url: '/pages/login'
uni.reLaunch({ url: '/pages/login' }) })
}) })
} } else if (code === 500) {
}) toast(msg)
reject('无效的会话,或者会话已过期,请重新登录。') reject(msg)
} else if (code === 500) { } else if (code !== 200) {
toast(msg) toast(msg)
reject(msg) reject(msg)
} else if (code !== 200) { }
toast(msg) resolve(res.data)
reject(msg) })
} .catch(error => {
resolve(res.data) let {
}) message
.catch(error => { } = error
let { message } = error if (message === 'Network Error') {
if (message === 'Network Error') { message = '后端接口连接异常'
message = '后端接口连接异常' } else if (message.includes('timeout')) {
} else if (message.includes('timeout')) { message = '系统接口请求超时'
message = '系统接口请求超时' } else if (message.includes('Request failed with status code')) {
} else if (message.includes('Request failed with status code')) { message = '系统接口' + message.substr(message.length - 3) + '异常'
message = '系统接口' + message.substr(message.length - 3) + '异常' }
} toast(message)
toast(message) reject(error)
reject(error) })
}) })
})
} }
export default request export default request