bindDelivery.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <div>
  3. <div class="take-out-list">
  4. <div class="item" v-for="(v, index) in deliveryList" :key="index">
  5. <div class="item-top">
  6. <div class="top-left">
  7. <img :src="v.logo" alt="" class="top-left-img" />
  8. <div class="name">{{ v.name }}</div>
  9. </div>
  10. <div v-if="v.bindStatus === 1" class="top-right">
  11. <span>开启后首选该账号平台为配送平台</span>
  12. <el-switch @change="statusDelivery(v)" v-model="v.preferredDelivery" :active-value="1" :inactive-value="0" />
  13. </div>
  14. </div>
  15. <div class="item-bottom">
  16. <div class="left">
  17. <div class="l-l">
  18. <img :src="v.pcLogo" class="l-l-img" />
  19. </div>
  20. <div class="take-out-name">
  21. <div v-if="v.shopNo">商户编号:{{ v.code }}</div>
  22. <div v-if="v.balance">账户余额:{{ v.balance }}</div>
  23. </div>
  24. </div>
  25. <!-- 1->绑定,0:未绑定,2-> 审核中,3->拒绝,4->待完善资料 -->
  26. <div class="right">
  27. <span class="reason">{{
  28. v.bindStatus === 2 ? "审核中" : v.bindStatus === 3 ? `已拒绝` : ""
  29. }}</span>
  30. <el-button v-if="[0, 3].includes(v.bindStatus)" @click="goBind(v)" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="关闭窗口后再操作!" type="primary" size="small" class="right-btn">去绑定</el-button>
  31. <el-button v-if="[1].includes(v.bindStatus)" @click="release(v)" size="small">解&nbsp;&nbsp;&nbsp;绑</el-button>
  32. <!-- <el-button v-if="v.bindStatus === 2" @click="release(v)" type="info" size="small">审核中</el-button> -->
  33. <!-- <el-button v-if="v.bindStatus === 3" @click="release(v)" type="danger" size="small">已拒绝</el-button> -->
  34. <el-button v-if="[1, 4].includes(v.bindStatus) && [1, 9].includes(v.type)" @click="perfectData(v)" type="primary" size="small" class="right-btn">完善资料</el-button>
  35. </div>
  36. </div>
  37. <div v-if="v.bindStatus === 3" class="respect">{{ v.authMsg }}</div>
  38. </div>
  39. </div>
  40. <!-- UU跑腿 -->
  41. <el-dialog :title="title" :visible.sync="centerDialogVisible" width="40%" center>
  42. <el-form v-if="title === 'UU跑腿绑定'" :model="UUData" ref="UUData" label-width="80px" class="demo-ruleForm">
  43. <el-form-item label="城市" prop="cityName" :rules="[{ required: true, message: '城市不能为空' }]">
  44. <el-input v-model="UUData.cityName" placeholder="请输入当前城市名称"></el-input>
  45. </el-form-item>
  46. <el-form-item label="手机号" prop="mobile" :rules="[{ required: true, message: '手机号不能为空' }]">
  47. <el-input v-model="UUData.mobile" placeholder="请输入用户手机号"></el-input>
  48. </el-form-item>
  49. <el-form-item label="验证码" prop="validateCode" :rules="[{ required: true, message: '验证码不能为空' }]">
  50. <div class="code">
  51. <el-input v-model="UUData.validateCode" placeholder="请输入验证码"></el-input>
  52. <div class="get-code" v-if="!showCode" @click.stop="getCode">
  53. 获取短信验证码
  54. </div>
  55. <div class="get-code" v-else>{{ count }}秒</div>
  56. </div>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button size="small" @click="resetForm('UUData')">取 消</el-button>
  60. <el-button size="small" type="primary" @click="bindUU">确 定</el-button>
  61. </el-form-item>
  62. </el-form>
  63. <el-form v-if="title === 'UU跑腿解绑'" :model="UUData" ref="UUData" label-width="80px" class="demo-ruleForm">
  64. <el-form-item label="手机号" prop="mobile" :rules="[{ required: true, message: '手机号不能为空' }]">
  65. <el-input v-model="UUData.mobile" placeholder="请输入用户手机号"></el-input>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button size="small" @click="resetForm('UUData')">取 消</el-button>
  69. <el-button size="small" type="primary" @click="releaseUU">确 定</el-button>
  70. </el-form-item>
  71. </el-form>
  72. </el-dialog>
  73. <!-- 完善资料 -->
  74. <el-dialog title="请输入达达门店编号" :visible.sync="centerDialogVisible2" width="40%" center>
  75. <div class="tips">请确保门店编号填写正确,否则会影响运力的使用!</div>
  76. <el-form :model="DDData" ref="DDData" label-width="80px" class="demo-ruleForm">
  77. <el-form-item label="门店编号" prop="shopNo">
  78. <el-input v-model="DDData.shopNo" placeholder="请输入门店编号"></el-input>
  79. </el-form-item>
  80. <el-form-item>
  81. <el-button size="small" @click="resetForm('DDData')">取 消</el-button>
  82. <el-button size="small" type="primary" @click="updateShopNo">确 定</el-button>
  83. </el-form-item>
  84. </el-form>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import {
  90. getDeliveryList,
  91. releaseDelivery,
  92. bindDelivery,
  93. bindUserApplyDelivery,
  94. bindUserSubmitDelivery,
  95. explainDelivery,
  96. updateShopNo,
  97. statusDelivery,
  98. cancelBindDelivery,
  99. } from "../../api/shop";
  100. export default {
  101. data() {
  102. return {
  103. deliveryList: [],
  104. jumpUrl: "",
  105. fullscreenLoading: false,
  106. centerDialogVisible: false,
  107. centerDialogVisible2: false,
  108. UUData: {
  109. cityName: "",
  110. mobile: "",
  111. validateCode: "",
  112. },
  113. title: "UU跑腿绑定",
  114. count: 60,
  115. showCode: false,
  116. timer: null, // 计时器
  117. DDData: {
  118. deliveryId: "",
  119. shopNo: "",
  120. },
  121. };
  122. },
  123. watch: {
  124. jumpUrl(newVal, oldVal) {
  125. if (this.jumpUrl) {
  126. this.fullscreenLoading = true;
  127. let newWindowWidth = 800,
  128. newWindowHeight = 500,
  129. left = (window.screen.width - newWindowWidth) / 2,
  130. top = (window.screen.height - newWindowHeight) / 2 - 100;
  131. let features = `width=${newWindowWidth},height=${newWindowHeight},left=${left},top=${top}`;
  132. let windowOpen = window.open(newVal, "name", features);
  133. let loop = window.setInterval(() => {
  134. console.log("windowOpen.closed", windowOpen.closed);
  135. if (windowOpen.closed) {
  136. this.jumpUrl = null;
  137. this.fullscreenLoading = false;
  138. window.clearInterval(loop);
  139. this.getDeliveryList(this.curIdx);
  140. }
  141. }, 1000);
  142. }
  143. },
  144. },
  145. created() {
  146. this.getDeliveryList();
  147. this.explainDelivery();
  148. },
  149. // 1->达达
  150. // 2->蜂鸟即配
  151. // 3->美团飞速达
  152. // 4->闪送
  153. // 5->顺丰同城
  154. // 7->UU跑腿
  155. // 8->爱跑腿
  156. // 9->达达优质
  157. // 10->快服务
  158. // 12->货拉拉
  159. methods: {
  160. explainDelivery() {
  161. explainDelivery().then((res) => {
  162. // console.log(res);
  163. });
  164. },
  165. getDeliveryList() {
  166. getDeliveryList().then((res) => {
  167. this.deliveryList = res.data;
  168. });
  169. },
  170. checkPhone(phone) {
  171. if (!/^1\d{10}$/.test(phone)) {
  172. return false;
  173. } else {
  174. return true;
  175. }
  176. },
  177. // 获取验证码
  178. getCode() {
  179. if (!this.UUData.mobile.trim()) {
  180. return this.$message({
  181. message: "手机号码不能为空",
  182. type: "error",
  183. });
  184. }
  185. if (!this.checkPhone(this.UUData.mobile)) {
  186. return this.$message({
  187. message: "请输入正确的手机号",
  188. type: "error",
  189. });
  190. }
  191. let params = {
  192. mobile: this.UUData.mobile,
  193. };
  194. bindUserApplyDelivery(params).then((res) => {
  195. if (res.code == 200) {
  196. this.showCode = true;
  197. this.$message({
  198. message: "验证码发送成功",
  199. type: "success",
  200. });
  201. this.timer = setInterval(() => {
  202. this.count--;
  203. if (this.count <= 1) {
  204. this.showCode = false;
  205. this.count = 60;
  206. clearInterval(this.timer);
  207. }
  208. }, 1000);
  209. } else {
  210. return this.$message({
  211. message: res.msg,
  212. type: "error",
  213. });
  214. }
  215. });
  216. },
  217. goBind(v) {
  218. let params = {
  219. deliveryId: v.deliveryId,
  220. };
  221. // 显示U跑腿绑定弹框
  222. if (v.type === 7) {
  223. this.title = "UU跑腿绑定";
  224. this.centerDialogVisible = true;
  225. return;
  226. }
  227. // 绑定顺丰同城
  228. if (v.type === 5) {
  229. this.$prompt("请输入顺丰同城ID", "提示", {
  230. confirmButtonText: "确定",
  231. cancelButtonText: "取消",
  232. center: true,
  233. })
  234. .then(({ value }) => {
  235. if (!value) {
  236. return this.$message({
  237. type: "error",
  238. message: "请输入正确的顺丰同城ID",
  239. });
  240. }
  241. params.sfId = value;
  242. bindDelivery(params).then((res) => {
  243. if (res.code === 200) {
  244. this.getDeliveryList();
  245. } else {
  246. this.$message({
  247. type: "error",
  248. message: res.msg,
  249. });
  250. }
  251. });
  252. })
  253. .catch(() => {
  254. return;
  255. });
  256. } else {
  257. bindDelivery(params).then((res) => {
  258. if (res.code === 200) {
  259. this.jumpUrl = res.data;
  260. } else {
  261. this.$message({
  262. type: "error",
  263. message: res.msg,
  264. });
  265. }
  266. });
  267. }
  268. },
  269. bindUU() {
  270. if (!this.UUData.cityName.trim()) {
  271. return this.$message({
  272. message: "城市不能为空",
  273. type: "error",
  274. });
  275. }
  276. if (!this.UUData.mobile.trim()) {
  277. return this.$message({
  278. message: "手机号不能为空",
  279. type: "error",
  280. });
  281. }
  282. if (!this.UUData.validateCode.trim()) {
  283. return this.$message({
  284. message: "验证码不能为空",
  285. type: "error",
  286. });
  287. }
  288. bindUserSubmitDelivery(this.UUData).then((res) => {
  289. if (res.code === 200) {
  290. this.$message({
  291. message: "绑定成功!",
  292. type: "success",
  293. });
  294. this.getDeliveryList();
  295. } else {
  296. this.$message({
  297. message: res.data,
  298. type: "error",
  299. });
  300. }
  301. this.centerDialogVisible = false;
  302. });
  303. },
  304. releaseUU() {
  305. if (!this.UUData.mobile.trim()) {
  306. return this.$message({
  307. message: "手机号不能为空",
  308. type: "error",
  309. });
  310. }
  311. cancelBindDelivery({ mobile: this.UUData.mobile }).then((res) => {
  312. if (res.code === 200) {
  313. this.$message({
  314. type: "success",
  315. message: "已成功解除绑定!",
  316. });
  317. this.getDeliveryList();
  318. } else {
  319. this.$message({
  320. type: "error",
  321. message: res.msg,
  322. });
  323. }
  324. this.centerDialogVisible = true;
  325. });
  326. },
  327. releaseSF(v) {
  328. this.$prompt("请输入顺丰同城ID", "提示", {
  329. confirmButtonText: "确定",
  330. cancelButtonText: "取消",
  331. center: true,
  332. }).then(({ value }) => {
  333. console.log(111, value);
  334. if (!value) {
  335. return this.$message({
  336. type: "error",
  337. message: "请输入正确的顺丰同城ID",
  338. });
  339. }
  340. v.sfId = value;
  341. this.confirmRelease(v);
  342. });
  343. },
  344. unBindDelivery(v) {
  345. unBindDelivery({ id: v.id }).then((res) => {
  346. if (res.code === 200) {
  347. this.$message({
  348. type: "success",
  349. message: "已成功解绑!",
  350. });
  351. this.getDeliveryList();
  352. } else {
  353. this.$message({
  354. type: "error",
  355. message: res.data,
  356. });
  357. }
  358. });
  359. },
  360. release(v) {
  361. // UU跑腿解除绑定
  362. if (v.type === 7) {
  363. this.title = "UU跑腿解绑";
  364. this.UUData.mobile = "";
  365. this.centerDialogVisible = true;
  366. return;
  367. }
  368. // 顺丰同程解绑
  369. if (v.type === 5) {
  370. this.releaseSF(v);
  371. return;
  372. }
  373. this.$confirm("此操作将解绑当前配送平台, 是否继续?", "提示", {
  374. confirmButtonText: "确定",
  375. cancelButtonText: "取消",
  376. type: "warning",
  377. })
  378. .then(() => {
  379. // 爱跑腿解除绑定
  380. if (v.type === 8) {
  381. this.unBindDelivery(v);
  382. return;
  383. }
  384. this.confirmRelease(v);
  385. })
  386. .catch(() => {
  387. this.$message({
  388. type: "info",
  389. message: "已取消解除绑定!",
  390. });
  391. });
  392. },
  393. // 确认解除绑定
  394. confirmRelease(v) {
  395. let params = {
  396. id: v.id,
  397. sfId: v.sfId,
  398. };
  399. releaseDelivery(params).then((res) => {
  400. if (res.code === 200) {
  401. this.$message({
  402. type: "success",
  403. message: "已成功解绑!",
  404. });
  405. this.getDeliveryList();
  406. } else {
  407. this.$message({
  408. type: "error",
  409. message: res.data,
  410. });
  411. }
  412. });
  413. },
  414. perfectData(v) {
  415. this.centerDialogVisible2 = true;
  416. this.DDData.deliveryId = v.deliveryId;
  417. this.DDData.shopNo = v.shopNo;
  418. },
  419. updateShopNo() {
  420. updateShopNo(this.DDData).then((res) => {
  421. if (res.code === 200) {
  422. this.$message({
  423. type: "success",
  424. message: "成功完善资料!",
  425. });
  426. this.getDeliveryList();
  427. } else {
  428. this.$message({
  429. type: "error",
  430. message: res.msg,
  431. });
  432. }
  433. this.centerDialogVisible2 = false;
  434. });
  435. },
  436. statusDelivery(v) {
  437. statusDelivery({
  438. id: v.id,
  439. preferredDelivery: v.preferredDelivery,
  440. }).then((res) => {
  441. if (res.code === 200) {
  442. this.$message({
  443. type: "success",
  444. message: "成功开启首选配送!",
  445. });
  446. } else {
  447. this.$message({
  448. type: "error",
  449. message: res.msg,
  450. });
  451. }
  452. this.getDeliveryList();
  453. });
  454. },
  455. resetForm(formName) {
  456. this.centerDialogVisible = false;
  457. this.centerDialogVisible2 = false;
  458. this.$refs[formName].resetFields();
  459. },
  460. },
  461. };
  462. </script>
  463. <style lang="scss" scoped>
  464. .store-list {
  465. display: flex;
  466. flex-wrap: nowrap;
  467. width: 100%;
  468. white-space: nowrap;
  469. overflow-x: auto;
  470. padding-bottom: 10px;
  471. &-item {
  472. padding: 8px 27px;
  473. background-color: #fff;
  474. font-size: 14px;
  475. font-family: PingFang SC;
  476. font-weight: 400;
  477. color: #b1b1b1;
  478. box-sizing: border-box;
  479. border: 1px solid #eee;
  480. border-radius: 17px;
  481. cursor: pointer;
  482. margin-right: 10px;
  483. &.active {
  484. color: #017e61;
  485. }
  486. }
  487. }
  488. .store-list::-webkit-scrollbar {
  489. height: 6px;
  490. }
  491. .store-list::-webkit-scrollbar-track {
  492. background-color: #eee;
  493. /*border-radius: 5px;
  494. -webkit-border-radius: 5px;
  495. -moz-border-radius: 5px;*/
  496. }
  497. .store-list::-webkit-scrollbar-thumb {
  498. background-color: #999;
  499. border-radius: 6px;
  500. -webkit-border-radius: 6px;
  501. -moz-border-radius: 6px;
  502. }
  503. .take-out-list {
  504. .item {
  505. background-color: #fff;
  506. margin-bottom: 10px;
  507. border-radius: 5px;
  508. padding-bottom: 10px;
  509. .item-top {
  510. display: flex;
  511. justify-content: space-between;
  512. box-sizing: border-box;
  513. padding: 20px 18px;
  514. align-items: center;
  515. border-bottom: 1px solid #eee;
  516. .top-left {
  517. display: flex;
  518. align-items: center;
  519. .top-left-img {
  520. width: 30px;
  521. height: 30px;
  522. margin-right: 10px;
  523. }
  524. .name {
  525. font-size: 16px;
  526. font-family: PingFang SC;
  527. font-weight: bold;
  528. color: #ffa608;
  529. }
  530. }
  531. .top-right {
  532. display: flex;
  533. align-items: center;
  534. span {
  535. font-size: 14px;
  536. font-family: PingFang SC;
  537. font-weight: 400;
  538. color: #b1b1b1;
  539. margin-right: 12px;
  540. }
  541. }
  542. }
  543. .item-bottom {
  544. display: flex;
  545. justify-content: space-between;
  546. box-sizing: border-box;
  547. padding: 25px 18px 0;
  548. align-items: center;
  549. .left {
  550. display: flex;
  551. align-items: center;
  552. .l-l {
  553. width: 166px;
  554. height: 50px;
  555. border-radius: 25px;
  556. overflow: hidden;
  557. font-size: 0;
  558. .l-l-img {
  559. width: 100%;
  560. height: 100%;
  561. }
  562. }
  563. .take-out-name {
  564. font-size: 13px;
  565. font-family: PingFang SC;
  566. font-weight: 400;
  567. color: #333333;
  568. line-height: 20px;
  569. margin-left: 30px;
  570. }
  571. }
  572. .right {
  573. .reason {
  574. margin-right: 10px;
  575. color: red;
  576. }
  577. .right-btn {
  578. background-color: #fc7200;
  579. border: none;
  580. }
  581. }
  582. }
  583. .respect {
  584. margin: 20px 20px 0;
  585. color: red;
  586. }
  587. }
  588. }
  589. .code {
  590. display: flex;
  591. align-items: center;
  592. .get-code {
  593. min-width: 120px;
  594. box-sizing: border-box;
  595. text-align: center;
  596. padding: 0 6px;
  597. font-size: 14px;
  598. font-family: PingFang SC;
  599. font-weight: 400;
  600. color: #175199;
  601. cursor: pointer;
  602. }
  603. }
  604. .tips {
  605. color: red;
  606. margin-bottom: 15px;
  607. }
  608. </style>