bindDelivery.vue 16 KB

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