Browse Source

公众号新增公众号二维码,新增商户端订单通知绑定

master
朱耘稷 4 years ago
parent
commit
8563d41795
  1. 46
      src/api/yxStoreCustomer.js
  2. 13
      src/utils/index.js
  3. 263
      src/views/shop/customer/index.vue
  4. 27
      src/views/wechat/config/index.vue

46
src/api/yxStoreCustomer.js

@ -0,0 +1,46 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/yxStoreCustomer',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/yxStoreCustomer/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'api/yxStoreCustomer',
method: 'put',
data
})
}
export function getqrcode() {
return request({
url: 'api/wxmp/qrcode',
method: 'get'
})
}
export function getOpenId(key) {
return request({
url: 'api/wxmp/getOpenId?key=' + key,
method: 'get'
})
}
export function getwechatCode() {
return request({
url: 'api/wxmp/wechatCode',
method: 'get'
})
}
export default { add, edit, del, getqrcode, getOpenId, getwechatCode }

13
src/utils/index.js

@ -419,3 +419,16 @@ export function downloadFile(obj, name, suffix) {
link.click() link.click()
document.body.removeChild(link) document.body.removeChild(link)
} }
export function RandomNumber() {
var min = 5; var max = 36
var randomStr = ''
var range = (max ? Math.round(Math.random() * (max - min)) + min : min)
var arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
for (var i = 0; i < range; i++) {
var index = Math.round(Math.random() * (arr.length - 1))
randomStr += arr[index]
}
return randomStr
}

263
src/views/shop/customer/index.vue

@ -0,0 +1,263 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input
v-model="query.nickName"
clearable
placeholder="输入用户昵称"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<el-input
v-model="query.remark"
clearable
placeholder="输入备注"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<rrOperation :crud="crud" />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
:before-close="crud.cancelCU"
:visible.sync="crud.status.cu > 0"
:title="crud.status.title"
width="750px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
<el-form-item label="用户昵称">
<el-input v-model="form.nickName" style="width: 485px;" :disabled="true" />
</el-form-item>
<el-form-item label="openId">
<el-input v-model="form.openId" style="width: 485px;" :disabled="true" />
</el-form-item>
<el-form-item label="门店二维码">
<div class="qrcode_img">
<el-image :src="src" class="qrcode">
<div slot="placeholder" class="image-slot">
加载中
<span class="dot">...</span>
</div>
</el-image>
</div>
<div class="qrcode_img">
<el-image :src="gzhsrc" class="qrcode">
<div slot="placeholder" class="image-slot">
加载中
<span class="dot">...</span>
</div>
</el-image>
<div class="attention">
<span class="demonstration">:未关注公众号请先关注</span>
</div>
</div>
</el-form-item>
<el-form-item label="备注" style="margin-top:40px">
<el-input v-model="form.remark" style="width: 485px;" />
</el-form-item>
<el-form-item label="是否启用">
<el-radio v-for="item in dict.is_enable" :key="item.id" v-model="form.isEnable" :label="item.value">{{ item.label }}</el-radio>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
size="small"
style="width: 100%;"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('id')" prop="id" label="id" />
<el-table-column v-if="columns.visible('nickName')" prop="nickName" label="用户昵称" />
<el-table-column v-if="columns.visible('openId')" prop="openId" label="用户标识" />
<el-table-column v-if="columns.visible('remark')" prop="remark" label="备注" />
<el-table-column v-if="columns.visible('isEnable')" prop="isEnable" label="是否启用">
<template slot-scope="scope">
{{ dict.label.is_enable[scope.row.isEnable] }}
</template>
</el-table-column>
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建时间">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
v-permission="['admin','yzCustomer:edit','yzCustomer:del']"
label="操作"
width="150px"
align="center"
>
<template slot-scope="scope">
<udOperation :data="scope.row" :permission="permission" />
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudYzCustomer from "@/api/yxStoreCustomer";
import CRUD, { presenter, header, form, crud } from "@crud/crud";
import rrOperation from "@crud/RR.operation";
import crudOperation from "@crud/CRUD.operation";
import udOperation from "@crud/UD.operation";
import pagination from "@crud/Pagination";
import { RandomNumber } from "@/utils/index";
// crudpresenter
const defaultCrud = CRUD({
title: "消息通知",
url: "api/yxStoreCustomer",
sort: "id,desc",
crudMethod: { ...crudYzCustomer }
});
const defaultForm = {
id: null,
nickName: null,
openId: null,
remark: null,
createTime: null,
updateTime: null
};
export default {
name: "yxStoreCustomer",
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
dicts: ['is_enable'],
data() {
return {
timer: null, //
src: "",
gzhsrc: "",
permission: {
add: ["admin", "yzCustomer:add"],
edit: ["admin", "yzCustomer:edit"],
del: ["admin", "yzCustomer:del"]
},
rules: {}
};
},
created() {
this.init();
},
methods: {
//
[CRUD.HOOK.beforeRefresh]() {
const query = this.query;
if (query.type && query.value) {
this.crud.params[query.type] = query.value;
}
return true;
},
[CRUD.HOOK.beforeToAdd]() {
this.randomStr = RandomNumber();
this.src =
process.env.VUE_APP_BASE_API + "/api/wxmp/qrcode?key=" + this.randomStr;
this.setIntervaltimer();
crudYzCustomer.getwechatCode()
//getOpenId("FK14YV17TURrFdyWG4")
.then(res => {
if (res != "") {
this.gzhsrc = res;
console.log(res);
}
})
.catch(err => {
console.log(err.response.data.message);
});
return true;
},
//
[CRUD.HOOK.afterToCU](crud, form) {
},
[CRUD.HOOK.beforeToCU]() {
this.randomStr = RandomNumber();
this.src =
process.env.VUE_APP_BASE_API + "/api/wxmp/qrcode?key=" + this.randomStr;
this.setIntervaltimer();
return true;
},
[CRUD.HOOK.afterAddCancel]() {
clearInterval(this.timer);
this.timer = null;
return true;
},
[CRUD.HOOK.afterEditCancel]() {
clearInterval(this.timer);
this.timer = null;
return true;
},
[CRUD.HOOK.afterAddCancel]() {
clearInterval(this.timer);
this.timer = null;
return true;
},
init() {},
setIntervaltimer() {
if (this.timer != null) {
clearInterval(this.timer);
this.timer = null;
}
this.timer = setInterval(() => {
crudYzCustomer.getOpenId(this.randomStr)
//getOpenId("FK14YV17TURrFdyWG4")
.then(res => {
if (res != "") {
this.form.nickName = res.nickName;
this.form.openId = res.openId;
clearInterval(this.timer);
this.timer = null;
}
})
.catch(err => {
console.log(err.response.data.message);
});
}, 2000);
return this.timer;
}
}
};
</script>
<style scoped>
.qrcode_img {
width: 250px;
height: 250px;
float: left;
}
.qrcode_img .qrcode {
width: 100%;
height: 100%;
}
.attention {
line-height: 0px;
color: red;
margin-left: 20px;
font-size: 19px;
}
</style>

27
src/views/wechat/config/index.vue

@ -17,7 +17,17 @@
<el-input v-model="form.api" :disabled="true" style="width: 370px;" /> <el-input v-model="form.api" :disabled="true" style="width: 370px;" />
</el-form-item> </el-form-item>
<el-form-item label="微信分享图片"> <el-form-item label="微信分享图片">
<MaterialList v-model="form.imageArr" style="width: 370px" type="image" :num="1" :width="150" :height="150" /> <MaterialList v-model="imageArr" style="width: 370px" type="image" :num="1" :width="150" :height="150" />
</el-form-item>
<el-form-item label="关注二维码">
<MaterialList
v-model="wechat_follow_imgArr"
style="width: 500px"
type="image"
:num="1"
:width="150"
:height="150"
/>
</el-form-item> </el-form-item>
<el-form-item label="微信分享标题"> <el-form-item label="微信分享标题">
<el-input v-model="form.wechat_share_title" style="width: 370px;" /> <el-input v-model="form.wechat_share_title" style="width: 370px;" />
@ -47,6 +57,8 @@ export default {
mixins: [initData], mixins: [initData],
data() { data() {
return { return {
wechat_follow_imgArr:[],
imageArr: [],
delLoading: false, delLoading: false,
form: { form: {
wechat_name: '', wechat_name: '',
@ -58,12 +70,12 @@ export default {
wechat_encode: '', wechat_encode: '',
wechat_encodingaeskey: '', wechat_encodingaeskey: '',
wechat_share_img: '', wechat_share_img: '',
imageArr: [], wechat_follow_img: '',
wechat_qrcode: '', wechat_qrcode: '',
wechat_type: '', wechat_type: '',
wechat_share_title: '', wechat_share_title: '',
wechat_share_synopsis: '', wechat_share_synopsis: '',
api: 'http://你的H5端域名/api/wechat/serve', api: 'http://你的yshop-app端域名/api/wechat/serve',
wechat_avatar: '' wechat_avatar: ''
}, },
rules: { rules: {
@ -71,10 +83,14 @@ export default {
} }
}, },
watch: { watch: {
'form.imageArr': function(val) { imageArr: function(val) {
if (val) { if (val) {
this.form.wechat_share_img = val.join(',') this.form.wechat_share_img = val.join(',')
} }
},wechat_follow_imgArr: function(val) {
if (val) {
this.form.wechat_follow_img = val.join(',')
}
} }
}, },
created() { created() {
@ -88,7 +104,8 @@ export default {
} }
}) })
this.form.imageArr = this.form.wechat_share_img.split(',') this.imageArr = this.form.wechat_share_img.split(',')
this.wechat_follow_imgArr = this.form.wechat_follow_img.split(',')
}) })
}, },
methods: { methods: {

Loading…
Cancel
Save