diff --git a/jiuyi2/api/mine.js b/jiuyi2/api/mine.js index d807e3f4..8e9a8646 100644 --- a/jiuyi2/api/mine.js +++ b/jiuyi2/api/mine.js @@ -107,6 +107,40 @@ const mine = { method: 'POST', }) }, + + /** + * 返回绑定微信 支付宝账号 + */ + getBindAccount() { + return util.request({ + url: '/user/Bind/getBindAccount', + method: 'GET', + }) + }, + + /** + * 绑定支付宝账号和微信账号 + * @param {Object} param + */ + bindAccount(param) { + return util.request({ + url: '/user/Bind/account', + data: param.data, + method: 'POST', + }) + }, + + /** + * 意见反馈 + * @param {Object} param + */ + feedback(param) { + return util.request({ + url: '/user/protocol/feedback', + data: param.data, + method: 'POST', + }) + }, } export default mine \ No newline at end of file diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index 9cf01232..5f34fd99 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -584,7 +584,7 @@ const util = { // 格式化默认值 // 图片计数 const count = obj.count ? obj.count : 8 - // 多战鼓图片 + // 多张图片 if (!obj.type) obj.type = 2 // 操作对象 if (obj.value != '' && obj.value == undefined && obj.value == null) obj.value = obj.type == 1 ? '' : [] diff --git a/jiuyi2/pages/mine/setting/binding.vue b/jiuyi2/pages/mine/setting/binding.vue index 695395b8..37a740d7 100644 --- a/jiuyi2/pages/mine/setting/binding.vue +++ b/jiuyi2/pages/mine/setting/binding.vue @@ -3,22 +3,26 @@ import { ref, computed, - getCurrentInstance + getCurrentInstance, + reactive } from 'vue' - import { - useStore - } from 'vuex' import { onLoad, onReady, } from '@dcloudio/uni-app' // 工具库 import util from '@/common/js/util.js' + // + import api from '@/api/index.js' + const { proxy } = getCurrentInstance() - // 仓库 - const store = useStore() + // 绑定的信息 + const detail = reactive({ + wechatId: '', + alipayId: '', + }) // 绑定的项 const bindItem = ref({}) // 用户信息 @@ -29,34 +33,81 @@ // 绑定列表 const bindList = computed(() => { let result = [{ + key: 'wechatId', img: '/static/wx.png', name: '微信号', - value: '', + value: detail.wechatId, }, { + key: 'alipayId', img: '/static/shop-alipay-payment.png', name: '支付宝号', - vlaue: '', + value: detail.alipayId, } ] return result }) - onReady(() => { - // + onLoad(() => { + // 获取绑定的信息 + getDetail() }) + // 获取绑定的信息 + function getDetail() { + api.mine.getBindAccount().then(rs => { + if (rs.code == 200) { + // 详情 + Object.assign(detail, rs.data) + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + // 点击项 function handleItem(item) { bindItem.value = item proxy.$refs.bind.open() } + + // 绑定支付宝号 + function handleSubmit() { + // 验证必填项 + if (!bindItem.value.name) { + util.alert(`${bindItem.name}不能为空`) + return + } + // 提交 + const data = {} + // 添加提交数据 + data[bindItem.value.key] = bindItem.value.value + + // + api.mine.bindAccount({ + data, + }).then(rs => { + if (rs.code == 200) { + // + detail[bindItem.value.key] = bindItem.value.value + // + proxy.$refs.bind.close() + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } -