bindTakeOut.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="take-out" v-loading="loading" element-loading-text="数据加载中">
  3. <div class="store-list">
  4. <div class="store-list-item" @click="curIdx = index" :class=" index === curIdx ? 'active' : '' " v-for="(item, index) in shopList" :key="index">{{ item.name }}</div>
  5. </div>
  6. <div class="take-out-list">
  7. <div class="item" v-for="(v,index) in takeOutList" :key="index">
  8. <div class="item-top">
  9. <div class="top-left">
  10. <img :src="v.logo" alt="" class="top-left-img">
  11. <div class="name">{{v.name}}</div>
  12. </div>
  13. <!-- <div class="top-right">
  14. <span>开启后自动接单</span>
  15. <el-switch />
  16. </div> -->
  17. </div>
  18. <div class="item-bottom">
  19. <div class="left">
  20. <div class="l-l">
  21. <img :src="v.pcLogo" class="l-l-img" />
  22. </div>
  23. <div class="take-out-name" v-if="v.bindStatus">
  24. <div>店铺名称:{{v.shopName}}</div>
  25. <div>店铺ID:{{v.thirdShopId}}</div>
  26. <div>配送门店:{{v.thirdShopName}}</div>
  27. </div>
  28. </div>
  29. <div class="right">
  30. <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>
  31. <el-button v-else @click="release(v)" size="small">解&nbsp;&nbsp;&nbsp;绑</el-button>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import {
  40. getShopList,
  41. getBindTakeOutList,
  42. getTakeOutList,
  43. bindTakeOut,
  44. deleteTakeOut,
  45. releaseTakeOut,
  46. setTakeOut,
  47. } from "../../api/shop";
  48. export default {
  49. data() {
  50. return {
  51. shopList: [],
  52. takeOutList: [],
  53. curIdx: -1,
  54. jumpUrl: "",
  55. fullscreenLoading: false,
  56. loading: true,
  57. };
  58. },
  59. watch: {
  60. curIdx(newVal, oldVal) {
  61. this.getBindTakeOutList(newVal);
  62. },
  63. jumpUrl(newVal, oldVal) {
  64. if (this.jumpUrl) {
  65. this.fullscreenLoading = true;
  66. let newWindowWidth = 800,
  67. newWindowHeight = 500,
  68. left = (window.screen.width - newWindowWidth) / 2,
  69. top = (window.screen.height - newWindowHeight) / 2 - 100;
  70. let features = `width=${newWindowWidth},height=${newWindowHeight},left=${left},top=${top}`;
  71. let windowOpen = window.open(newVal, "name", features);
  72. let loop = window.setInterval(() => {
  73. console.log("windowOpen.closed", windowOpen.closed);
  74. if (windowOpen.closed) {
  75. this.jumpUrl = null;
  76. this.fullscreenLoading = false;
  77. window.clearInterval(loop);
  78. this.getBindTakeOutList(this.curIdx);
  79. }
  80. }, 1000);
  81. }
  82. },
  83. },
  84. created() {
  85. getShopList().then((res) => {
  86. this.loading = true;
  87. getShopList().then((res) => {
  88. if (res.code === 200) {
  89. this.shopList = res.data;
  90. this.curIdx = 0;
  91. } else {
  92. this.$message({
  93. type: "error",
  94. message: res.msg,
  95. });
  96. }
  97. this.loading = false;
  98. });
  99. });
  100. },
  101. methods: {
  102. getBindTakeOutList(index) {
  103. getBindTakeOutList({ shopId: this.shopList[index].id }).then((res) => {
  104. if (res.code === 200) {
  105. this.takeOutList = res.data;
  106. } else {
  107. this.$message({
  108. type: "error",
  109. message: res.msg,
  110. });
  111. }
  112. });
  113. },
  114. goBind(v) {
  115. let params = {
  116. shopId: this.shopList[this.curIdx].id,
  117. waimaiId: v.waimaiId,
  118. isNew: 1,
  119. };
  120. bindTakeOut(params).then((res) => {
  121. if (res.code === 200) {
  122. this.jumpUrl = res.data;
  123. } else {
  124. this.$message({
  125. type: "error",
  126. message: res.msg,
  127. });
  128. }
  129. });
  130. },
  131. release(v) {
  132. this.$confirm("解绑后将无法同步店铺订单,确认要解绑吗?", "提示", {
  133. confirmButtonText: "确定",
  134. cancelButtonText: "取消",
  135. type: "warning",
  136. })
  137. .then(() => {
  138. releaseTakeOut({ id: v.id }).then((res) => {
  139. if (res.code === 200) {
  140. if (res.data) {
  141. this.jumpUrl = res.data;
  142. } else {
  143. this.$message({
  144. type: "success",
  145. message: "成功解绑!",
  146. });
  147. this.getBindTakeOutList(this.curIdx);
  148. }
  149. } else {
  150. this.$message({
  151. type: "error",
  152. message: res.msg,
  153. });
  154. }
  155. });
  156. })
  157. .catch(() => {
  158. this.$message({
  159. type: "info",
  160. message: "已取消解绑!",
  161. });
  162. });
  163. },
  164. },
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. .take-out {
  169. min-height: 200px;
  170. .store-list {
  171. display: flex;
  172. flex-wrap: nowrap;
  173. width: 100%;
  174. white-space: nowrap;
  175. overflow-x: auto;
  176. padding-bottom: 10px;
  177. &-item {
  178. padding: 8px 27px;
  179. background-color: #fff;
  180. font-size: 14px;
  181. font-family: PingFang SC;
  182. font-weight: 400;
  183. color: #b1b1b1;
  184. box-sizing: border-box;
  185. border: 1px solid #eee;
  186. border-radius: 17px;
  187. cursor: pointer;
  188. margin-right: 10px;
  189. &.active {
  190. color: #fc7200;
  191. }
  192. }
  193. }
  194. .store-list::-webkit-scrollbar {
  195. height: 6px;
  196. }
  197. .store-list::-webkit-scrollbar-track {
  198. background-color: #eee;
  199. /*border-radius: 5px;
  200. -webkit-border-radius: 5px;
  201. -moz-border-radius: 5px;*/
  202. }
  203. .store-list::-webkit-scrollbar-thumb {
  204. background-color: #999;
  205. border-radius: 6px;
  206. -webkit-border-radius: 6px;
  207. -moz-border-radius: 6px;
  208. }
  209. .take-out-list {
  210. .item {
  211. background-color: #fff;
  212. .item-top {
  213. display: flex;
  214. justify-content: space-between;
  215. box-sizing: border-box;
  216. padding: 20px 18px;
  217. align-items: center;
  218. border-bottom: 1px solid #eee;
  219. .top-left {
  220. display: flex;
  221. align-items: center;
  222. .top-left-img {
  223. width: 30px;
  224. height: 30px;
  225. margin-right: 10px;
  226. }
  227. .name {
  228. font-size: 16px;
  229. font-family: PingFang SC;
  230. font-weight: bold;
  231. color: #ffa608;
  232. }
  233. }
  234. .top-right {
  235. display: flex;
  236. align-items: center;
  237. span {
  238. font-size: 14px;
  239. font-family: PingFang SC;
  240. font-weight: 400;
  241. color: #b1b1b1;
  242. margin-right: 12px;
  243. }
  244. }
  245. }
  246. .item-bottom {
  247. display: flex;
  248. justify-content: space-between;
  249. box-sizing: border-box;
  250. padding: 25px 18px;
  251. align-items: center;
  252. .left {
  253. display: flex;
  254. align-items: center;
  255. .l-l {
  256. width: 160px;
  257. height: 50px;
  258. font-size: 0;
  259. .l-l-img {
  260. width: 100%;
  261. height: 100%;
  262. }
  263. }
  264. .take-out-name {
  265. font-size: 13px;
  266. font-family: PingFang SC;
  267. font-weight: 400;
  268. color: #333333;
  269. line-height: 20px;
  270. margin-left: 30px;
  271. }
  272. }
  273. .right {
  274. .right-btn {
  275. background-color: #fc7200;
  276. border: #fc7200;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. </style>