123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div class="take-out" v-loading="loading" element-loading-text="数据加载中">
- <div class="store-list">
- <div class="store-list-item" @click="curIdx = index" :class=" index === curIdx ? 'active' : '' " v-for="(item, index) in shopList" :key="index">{{ item.name }}</div>
- </div>
- <div class="take-out-list">
- <div class="item" v-for="(v,index) in takeOutList" :key="index">
- <div class="item-top">
- <div class="top-left">
- <img :src="v.logo" alt="" class="top-left-img">
- <div class="name">{{v.name}}</div>
- </div>
- <!-- <div class="top-right">
- <span>开启后自动接单</span>
- <el-switch />
- </div> -->
- </div>
- <div class="item-bottom">
- <div class="left">
- <div class="l-l">
- <img :src="v.pcLogo" class="l-l-img" />
- </div>
- <div class="take-out-name" v-if="v.bindStatus">
- <div>店铺名称:{{v.shopName}}</div>
- <div>店铺ID:{{v.thirdShopId}}</div>
- <div>配送门店:{{v.thirdShopName}}</div>
- </div>
- </div>
- <div class="right">
- <el-button v-if="!v.bindStatus" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="关闭窗口后再操作!" type="primary" size="small" class="right-btn" @click="goBind(v)">去绑定</el-button>
- <el-button v-else @click="release(v)" size="small">解 绑</el-button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- getShopList,
- getBindTakeOutList,
- getTakeOutList,
- bindTakeOut,
- deleteTakeOut,
- releaseTakeOut,
- setTakeOut,
- } from "../../api/shop";
- export default {
- data() {
- return {
- shopList: [],
- takeOutList: [],
- curIdx: -1,
- jumpUrl: "",
- fullscreenLoading: false,
- loading: true,
- };
- },
- watch: {
- curIdx(newVal, oldVal) {
- this.getBindTakeOutList(newVal);
- },
- jumpUrl(newVal, oldVal) {
- if (this.jumpUrl) {
- this.fullscreenLoading = true;
- let newWindowWidth = 800,
- newWindowHeight = 500,
- left = (window.screen.width - newWindowWidth) / 2,
- top = (window.screen.height - newWindowHeight) / 2 - 100;
- let features = `width=${newWindowWidth},height=${newWindowHeight},left=${left},top=${top}`;
- let windowOpen = window.open(newVal, "name", features);
- let loop = window.setInterval(() => {
- console.log("windowOpen.closed", windowOpen.closed);
- if (windowOpen.closed) {
- this.jumpUrl = null;
- this.fullscreenLoading = false;
- window.clearInterval(loop);
- this.getBindTakeOutList(this.curIdx);
- }
- }, 1000);
- }
- },
- },
- created() {
- getShopList().then((res) => {
- this.loading = true;
- getShopList().then((res) => {
- if (res.code === 200) {
- this.shopList = res.data;
- this.curIdx = 0;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- this.loading = false;
- });
- });
- },
- methods: {
- getBindTakeOutList(index) {
- getBindTakeOutList({ shopId: this.shopList[index].id }).then((res) => {
- if (res.code === 200) {
- this.takeOutList = res.data;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- goBind(v) {
- let params = {
- shopId: this.shopList[this.curIdx].id,
- waimaiId: v.waimaiId,
- isNew: 1,
- };
- bindTakeOut(params).then((res) => {
- if (res.code === 200) {
- this.jumpUrl = res.data;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- release(v) {
- this.$confirm("解绑后将无法同步店铺订单,确认要解绑吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- releaseTakeOut({ id: v.id }).then((res) => {
- if (res.code === 200) {
- if (res.data) {
- this.jumpUrl = res.data;
- } else {
- this.$message({
- type: "success",
- message: "成功解绑!",
- });
- this.getBindTakeOutList(this.curIdx);
- }
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消解绑!",
- });
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .take-out {
- min-height: 200px;
- .store-list {
- display: flex;
- flex-wrap: nowrap;
- width: 100%;
- white-space: nowrap;
- overflow-x: auto;
- padding-bottom: 10px;
- &-item {
- padding: 8px 27px;
- background-color: #fff;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #b1b1b1;
- box-sizing: border-box;
- border: 1px solid #eee;
- border-radius: 17px;
- cursor: pointer;
- margin-right: 10px;
- &.active {
- color: #fc7200;
- }
- }
- }
- .store-list::-webkit-scrollbar {
- height: 6px;
- }
- .store-list::-webkit-scrollbar-track {
- background-color: #eee;
- /*border-radius: 5px;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;*/
- }
- .store-list::-webkit-scrollbar-thumb {
- background-color: #999;
- border-radius: 6px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- }
- .take-out-list {
- .item {
- background-color: #fff;
- .item-top {
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 20px 18px;
- align-items: center;
- border-bottom: 1px solid #eee;
- .top-left {
- display: flex;
- align-items: center;
- .top-left-img {
- width: 30px;
- height: 30px;
- margin-right: 10px;
- }
- .name {
- font-size: 16px;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffa608;
- }
- }
- .top-right {
- display: flex;
- align-items: center;
- span {
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #b1b1b1;
- margin-right: 12px;
- }
- }
- }
- .item-bottom {
- display: flex;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 25px 18px;
- align-items: center;
- .left {
- display: flex;
- align-items: center;
- .l-l {
- width: 160px;
- height: 50px;
- font-size: 0;
- .l-l-img {
- width: 100%;
- height: 100%;
- }
- }
- .take-out-name {
- font-size: 13px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #333333;
- line-height: 20px;
- margin-left: 30px;
- }
- }
- .right {
- .right-btn {
- background-color: #fc7200;
- border: #fc7200;
- }
- }
- }
- }
- }
- }
- </style>
|