| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- <div id="app" class="diy-index" v-cloak ref="contain" v-loading="loading">
- <div class="nav">店铺装修</div>
- <div class="header_box" style="flex: 1;">
- <div ref="crad-header" class="add_temp_box flex flex-x-between flex-y-center">
- <div class="add_temp_left flex flex-y-center">
- <p style="margin-right: 30px;">页面管理</p>
- <el-button type="primary" style="width: 162px;height:40px" @click="$navigate({r: 'mall/diy/edit'})">新建页面</el-button>
- </div>
- <div class="add_temp_right">
- <el-input placeholder="输入页面关键词搜索" v-model='title' suffix-icon="el-icon-search" @change='changeName'></el-input>
- </div>
- </div>
- <div style="flex: 1;margin-top:10px">
- <el-table :data="temp_list">
- <el-table-column prop="id" label="页面ID" width="100"></el-table-column>
- <el-table-column prop="title" label="页面名称">
- <template slot-scope="scope">
- <i v-if="scope.row.is_home_page == 1" class="el-icon-s-home" style="color: #0A54EA;font-size: 16px;"></i>
- <i v-if="scope.row.template == 'goods_detail'" class="el-icon-s-goods" style="color: #0A54EA;font-size: 16px;"></i>
- <i v-if="scope.row.template == 'user_center'" class="el-icon-user-solid" style="color: #0A54EA;font-size: 16px;"></i>
- {{ scope.row.title }}
- </template>
- </el-table-column>
- <el-table-column prop="is_home_page" label="页面类型">
- <template slot-scope="scope">
- <el-tag v-if="scope.row.template == 'home_page' && scope.row.is_home_page == 1" effect="plain" size="medium" style="margin-right: 5px;"> 首页 </el-tag>
- <el-tag v-else effect="plain" :type="scope.row.template == 'custom_page' ? 'info' : ''" size="medium"> {{template[scope.row.template]}} </el-tag>
- </template>
- </el-table-column>
- <el-table-column prop="created_at" label="创建时间">
- <template slot-scope="scope">
- <div>{{ scope.row.created_at | dateTimeFormat('Y-m-d H:i')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="600">
- <template slot-scope="scope">
- <el-breadcrumb separator="|">
- <el-breadcrumb-item>
- <span class="operation" @click="handle('edit', scope.row)">编辑</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="isShoeDeletePage(scope.row)">
- <span class="operation" @click="handle('destroy', scope.row)">删除</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="no_copy_template.indexOf(scope.row.template) == -1">
- <span class="operation" @click="handle('copy_page', scope.row)">复制页面</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="no_copy_url.indexOf(scope.row.template) == -1">
- <span class="operation copy_btn" @click="handle('copy_link', scope.row)">复制链接</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="no_copy_url.indexOf(scope.row.template) == -1 && alipay_mini_app_id">
- <span class="operation copy_alipay_mini_url_btn" @click="handle('copy_alipay_mini_link', scope.row)">支付宝链接</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="no_copy_url.indexOf(scope.row.template) == -1">
- <span class="operation" @click="handle('qrcode', scope.row)">二维码</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="isShoeSetPage(scope.row)">
- <span class="operation" @click="handle('set_home', scope.row)">设为首页</span>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="isShoeSetPage(scope.row)">
- <span class="operation" @click="handle('set_show_nav', scope.row)">
- {{scope.row.is_show_bottom_nav == 1 ? '隐藏导航' : '显示导航'}}
- </span>
- </el-breadcrumb-item>
- </el-breadcrumb>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div style="text-align: right;margin: 20px 0;" ref="page">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </div>
- <!-- 二维码 -->
- <div id="qrcode-info" style="position: fixed;top: 10000000000px;">
- <!-- 二维码 -->
- <div id="qrcode" style="width:150px; height:150px;"></div>
- </div>
- <el-dialog :close-on-click-modal="false" v-loading="posterLoading" element-loading-text="二维码生成中" title="二维码" :visible.sync="sharePop" width="30%">
- <el-form ref="shareData" :model="shareData" label-width="80px">
- <el-form-item label="">
- <el-image style="width: 144px; height: 144px; margin-left: 25%;" :src="shareData.img"></el-image>
- </el-form-item>
- </el-form>
- </el-dialog>
- <!--支付宝小程序链接复制-->
- <el-dialog :close-on-click-modal="false" title="支付支付宝小程序链接" :visible.sync="copyAlipayMiniDialogVisible" width="50%">
- <el-form>
- <el-form-item label="页面路径及参数">
- <el-input v-model="alipay_path" :disabled="true">
- <template #append>
- <el-button @click="onCopyAlipayUrl(alipay_path, 'btn-copy-alipay-path')" class="btn-copy-alipay-path">复制</el-button>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item label="支付宝小程序URL(参数已转)">
- <el-input v-model="alipay_mini_path" :disabled="true">
- <template #append>
- <el-button @click="onCopyAlipayUrl(alipay_mini_path, 'btn-copy-alipay-mini-path')" class="btn-copy-alipay-mini-path">复制</el-button>
- </template>
- </el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="copyAlipayMiniDialogVisible = false">关 闭</el-button>
- </span>
- </el-dialog>
- </div>
- <script src="/resources/unpkg/clipboard@1.5.12/dist/clipboard.min.js"></script>
- <script>
- new Vue({
- el: '#app',
- data() {
- return {
- loading: false,
- template: [],
- temp_list: [],
- title: null,
- no_copy_template: ['goods_detail','user_center'],
- no_copy_url: ['goods_detail'],
- page: 1,
- pageCount: 0,
- posterLoading: false,
- sharePop: false, //分享弹窗
- shareData: {
- img: ''
- },
- alipay_mini_app_id: null,
- copyAlipayMiniDialogVisible: false,
- alipay_path: '',
- alipay_mini_path: ''
- }
- },
- watch: {
- direction(newVal) { //控制图片随鼠标上下滑动而滑动
- if (newVal == 'up') { //分成两个方法为了方便控制上下滚动
- clearInterval(this.timerDown)
- this.rollingUp();
- } else {
- clearInterval(this.timerUp)
- this.rollingDown();
- }
- }
- },
- created() {
- this.getList();
- },
- methods: {
- isShoeSetPage(item) {
- return item.is_home_page == 0 && (item.template == 'home_page' || item.type == 1)
- },
- isShoeDeletePage(item) {
- return item.is_home_page != 1 && item.type == 1
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- handleEdit(index, row) {
- console.log(index, row);
- },
- handleDelete(index, row) {
- console.log(index, row);
- },
- async handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- switch (type) {
- case 'edit':
- let params = {
- r: 'mall/diy/edit'
- };
- if (id) params = Object.assign(params, {
- id: id
- });
- navigateTo(params);
- break;
- case 'destroy':
- if (data.type == 2) {
- this.$message.error('该页面不允许删除!');
- return false;
- }
- param = {
- id: data.id
- };
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
- type: 'warning'
- }).then(() => {
- this.send(param, 'mall/diy/delete')
- })
- break;
- case 'copy_page':
- param = {
- id: data.id
- };
- this.send(param, 'mall/diy/copy-page');
- break;
- case 'set_home':
- param = {
- id: data.id,
- };
- this.send(param, 'mall/diy/set-home');
- break;
- case 'copy_link':
- this.copyLink(data);
- break;
- case 'copy_alipay_mini_link':
- this.copyAlipayMiniLink(data);
- break;
- case 'qrcode':
- let codeImgSrc = await this.getQrCode(data.web_url);
- this.shareData.img = codeImgSrc;
- this.sharePop = true;
- break;
- case 'set_show_nav':
- param = {
- id: data.id,
- };
- this.send(param, 'mall/diy/set-show-nav');
- break;
- }
- },
- send(params, url = '') {
- let self = this;
- request({
- params: {
- r: url,
- },
- method: 'post',
- data: params
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- copyLink(data) { //复制链接
- var clipboard = new ClipboardJS('.copy_btn', {
- text: function() {
- return data.web_url;
- }
- });
- clipboard.on('success', (e) => {
- this.$message.success('复制成功!');
- e.clearSelection()
- clipboard.destroy()
- });
- clipboard.on('error', (e) => {
- this.$message.error('复制失败!');
- this.clipboard.destroy()
- });
- },
- copyAlipayMiniLink(data) { //复制链接
- if (isEmpty(data.alipay_mini_link)) {
- this.$message.error("请设置商城的H5域名");
- return;
- }
- let paths = data.web_url.split('#')
- console.log(paths)
- if (paths.length > 1) {
- this.alipay_path = `&${paths[1]}`;
- } else {
- this.alipay_path = data.alipay_mini_link
- }
- this.alipay_mini_path = data.alipay_mini_link;
- this.copyAlipayMiniDialogVisible = true;
- },
- onCopyAlipayUrl(str, btn) {
- let clipboard = new ClipboardJS(`.${btn}`, {
- text: function() {
- return str;
- }
- });
- clipboard.on('success', (e) => {
- this.$message.success('复制成功!');
- e.clearSelection()
- clipboard.destroy()
- });
- clipboard.on('error', (e) => {
- this.$message.error('复制失败!');
- this.clipboard.destroy()
- });
- },
- changeName(e) {
- this.title = e;
- this.getList();
- },
- getList() {
- this.loading = true;
- this.$request({
- params: {
- r: 'mall/diy/index',
- title: this.title,
- page: this.page
- },
- method: 'get',
- }).then(e => {
- this.loading = false;
- if (e.data.code == 0) {
- this.temp_list = e.data.data.list;
- this.template = e.data.data.template;
- this.pageCount = e.data.data.page_count;
- this.alipay_mini_app_id = e.data.data.alipay_mini_app_id
- }
- });
- },
- handleClose(done) {
- this.dialogVisible = false;
- clearInterval(this.timerUp);
- clearInterval(this.timerDown);
- this.scrolltop = 0;
- this.$refs.uContent.scrollTop = 0;
- },
- enterImg() { //进入图片事件
- setTimeout(() => { //加一个延时,防止鼠标刚移进去图片就开始动
- this.is_begin = true;
- }, 1000)
- },
- imgMove(e) { //图片滚动事件
- if (!this.is_begin) return;
- if (this.clientY != 0) {
- if (this.clientY > e.clientY) {
- this.direction = 'up';
- } else {
- this.direction = 'down';
- }
- };
- this.clientY = e.clientY;
- },
- rollingDown() {
- this.timerDown = setInterval(() => {
- if (this.$refs.uContent.scrollHeight - 696 >= this.scrolltop) {
- this.scrolltop = this.scrolltop + this.speed;
- this.$refs.uContent.scrollTop = this.scrolltop;
- } else {
- clearInterval(this.timerDown);
- }
- }, 2)
- },
- rollingUp() {
- this.timerUp = setInterval(() => {
- if (this.$refs.uContent.scrollTop <= 0) {
- clearInterval(this.timerUp);
- } else {
- this.scrolltop = this.scrolltop - this.speed;
- this.$refs.uContent.scrollTop = this.scrolltop;
- }
- }, 2)
- },
- // 生成二维码
- getQrCode(url) {
- let qrcodeInfo = document.getElementById("qrcode-info");
- document.getElementById("qrcode").remove(); //删除生成的二维码
- let addCodeDom = document.createElement("div")
- addCodeDom.setAttribute("id", "qrcode");
- addCodeDom.setAttribute("style", "width:300px; height:300px;");
- qrcodeInfo.appendChild(addCodeDom) //添加标签
- let qrCodeDom = document.getElementById("qrcode")
- var qrcode = new QRCode(qrCodeDom, {
- width: 300,
- height: 300
- });
- qrcode.makeCode(url);
- // 获取二维码生成的图片信息
- let src = "";
- return new Promise((req, rej) => {
- setTimeout(() => {
- src = qrCodeDom.getElementsByTagName("img")[0].src;
- req(src)
- }, 200);
- })
- },
- }
- })
- </script>
- <style scoped>
- .nav {
- background: #ffffff;
- border-radius: 5px;
- padding: 26px 24px;
- margin-bottom: 10px;
- }
- .diy-index {
- display: flex;
- flex-direction: column;
- }
- .header_box {
- display: flex;
- flex-direction: column;
- padding: 25px;
- background: #fff;
- border-radius: 5px 5px 0 0;
- color: #808695;
- }
- .add_temp_right {
- width: 400px;
- }
- .operation {
- cursor: pointer;
- color: #409eff;
- }
- .operation:hover {
- color: #fb6638;
- }
- /* 公共样式 */
- .flex {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- }
- .flex-x-center {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- -ms-flex-pack: center;
- justify-content: center;
- }
- .flex-x-between {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-pack: space-between;
- -webkit-justify-content: space-between;
- -ms-flex-pack: space-between;
- justify-content: space-between;
- }
- .flex-y-center {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-align: center;
- -webkit-align-items: center;
- -ms-flex-align: center;
- -ms-grid-row-align: center;
- align-items: center;
- }
- /* 溢出隐藏 */
- .over1 {
- text-overflow: -o-ellipsis-lastline;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- }
- .el-card {
- background: transparent;
- box-shadow: none !important;
- border: 0;
- }
- .el-card__body {
- padding: 0;
- }
- .el-table td,
- .el-table th {
- padding: 12px 0
- }
- </style>
|