bindDelivery.vue 18 KB

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