index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="scanCode">
  3. <div class="form" v-if="info.id">
  4. <div class="title-box">
  5. <div class="status" style="color: white">已预约</div>
  6. <div class="title">预约码</div>
  7. <div class="status">{{ info.statusStr }}&nbsp;</div>
  8. </div>
  9. <div class="form-data">
  10. <div class="form-item">
  11. <div class="item-label">对应码头</div>
  12. <div class="item-value">{{ info.dockCode }}</div>
  13. </div>
  14. <div class="form-item">
  15. <div class="item-label">预约目的</div>
  16. <div class="item-value">{{ info.loadType }}</div>
  17. </div>
  18. <div class="form-item">
  19. <div class="item-label">集装箱车辆</div>
  20. <div class="item-value">{{ info.carType }}</div>
  21. </div>
  22. <div class="form-item">
  23. <div class="item-label">预约日期</div>
  24. <div class="item-value">{{ info.reservationDate }}</div>
  25. </div>
  26. <div class="form-item">
  27. <div class="item-label">所属企业</div>
  28. <div class="item-value">{{ info.businessName }}</div>
  29. </div>
  30. <div class="form-item">
  31. <div class="item-label">司机姓名</div>
  32. <div class="item-value">{{ info.driverName }}</div>
  33. </div>
  34. <div class="form-item">
  35. <div class="item-label">车牌号</div>
  36. <div class="item-value">{{ info.carNo }}</div>
  37. </div>
  38. <div class="form-item">
  39. <div class="item-label">件数/托盘数</div>
  40. <div class="item-value">{{ info.loadNum }}</div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="btn">
  45. <van-button
  46. color="rgba(138, 5, 84, 1)"
  47. type="primary"
  48. @click="scanCode()"
  49. >
  50. 重新扫码
  51. </van-button>
  52. <van-button
  53. v-if="info.statusStr == '待签到'"
  54. color="rgba(138, 5, 84, 1)"
  55. type="primary"
  56. @click="doReservationSign()"
  57. >
  58. 签到确认
  59. </van-button>
  60. <van-button
  61. v-if="info.statusStr == '装卸中'"
  62. color="rgba(138, 5, 84, 1)"
  63. type="primary"
  64. @click="doReservationFinish()"
  65. >
  66. 装卸完成
  67. </van-button>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. // /wx/dock/getReservationVoById
  73. import {
  74. getReservationVoById,
  75. doReservationSign,
  76. doReservationFinish,
  77. } from "@/js_sdk/sjTools.js";
  78. import { getUserLocalStorageInfo } from "@/js_sdk/localUserInfo.js";
  79. import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue";
  80. export default {
  81. data() {
  82. return {
  83. url: "",
  84. modal_qr: false,
  85. info: {},
  86. id: "",
  87. };
  88. },
  89. components: { ayQrcode },
  90. onLoad(e) {
  91. console.log(e);
  92. this.scanCode();
  93. // this.getReservationVoById(e.id);
  94. },
  95. methods: {
  96. async doReservationFinish() {
  97. let data = await doReservationFinish({
  98. id: this.id,
  99. userId: getUserLocalStorageInfo().user.id,
  100. });
  101. if (data.errmsg == "成功") {
  102. this.$showToast("操作成功");
  103. this.getReservationVoById();
  104. }
  105. },
  106. async doReservationSign() {
  107. let data = await doReservationSign({
  108. id: this.id,
  109. userId: getUserLocalStorageInfo().user.id,
  110. });
  111. if (data.errmsg == "成功") {
  112. this.$showToast("签到成功");
  113. this.getReservationVoById();
  114. }
  115. },
  116. scanCode() {
  117. wx.scanCode({
  118. onlyFromCamera: true,
  119. // scanType: ["qrCode"],
  120. success: (res) => {
  121. console.log(res.result); // 扫码结果
  122. this.id = res.result.split('id=')[1];
  123. this.getReservationVoById();
  124. // 根据扫码结果进行后续处理
  125. // 例如,使用wx.navigateTo跳转到新的页面,并传递扫码结果作为参数
  126. // wx.navigateTo({
  127. // url: '/path/to/page?scanResult=' + encodeURIComponent(res.result)
  128. // })
  129. },
  130. fail: (err) => {
  131. console.error(err);
  132. // 处理扫码失败的情况
  133. wx.showToast({
  134. title: "扫码失败",
  135. icon: "none",
  136. });
  137. },
  138. });
  139. },
  140. async getReservationVoById() {
  141. let { data } = await getReservationVoById({ id: this.id });
  142. console.log(data);
  143. this.info = data;
  144. },
  145. wxShare(e) {
  146. console.log(e);
  147. },
  148. hideQrcode() {
  149. this.modal_qr = false;
  150. },
  151. onShareAppMessage(res) {
  152. //发送给朋友
  153. console.log(`分享到朋友圈`, res);
  154. },
  155. onShareTimeline(res) {
  156. //分享到朋友圈
  157. console.log(`分享到朋友圈`, res);
  158. return {};
  159. },
  160. },
  161. };
  162. </script>
  163. <style lang="scss">
  164. .scanCode {
  165. margin-top: 24rpx;
  166. .btn {
  167. display: flex;
  168. justify-content: space-around;
  169. position: absolute;
  170. bottom: 0;
  171. padding: 20rpx;
  172. width: 100%;
  173. box-sizing: border-box;
  174. left: 0;
  175. padding-bottom: 40rpx;
  176. button {
  177. width: 200rpx;
  178. // margin-top: 120rpx;
  179. }
  180. }
  181. .form {
  182. background: white;
  183. padding: 32rpx;
  184. }
  185. .sharbtn {
  186. margin: auto;
  187. // display: block;
  188. padding: 0;
  189. border: none;
  190. height: 112rpx;
  191. width: 112rpx;
  192. background: rgba(0, 0, 0, 0);
  193. &:after {
  194. border: none;
  195. }
  196. }
  197. .tips {
  198. color: rgba(102, 102, 102, 1);
  199. margin-top: 32rpx;
  200. text-align: center;
  201. }
  202. .wxicon {
  203. height: 112rpx;
  204. width: 112rpx;
  205. }
  206. .form-data {
  207. box-sizing: border-box;
  208. padding: 0 80rpx;
  209. .code {
  210. margin-top: 16rpx;
  211. width: 320rpx;
  212. height: 320rpx;
  213. // background: #5c5c5c;
  214. margin: 16rpx auto;
  215. }
  216. .form-item {
  217. display: flex;
  218. margin-top: 15rpx;
  219. align-items: center;
  220. }
  221. .item-label {
  222. font-weight: 400;
  223. font-size: 32rpx;
  224. color: #333333;
  225. width: 175rpx;
  226. }
  227. .item-value {
  228. font-weight: 400;
  229. margin-left: 48rpx;
  230. font-size: 32rpx;
  231. color: #666666;
  232. }
  233. }
  234. .title-box {
  235. display: flex;
  236. box-sizing: border-box;
  237. justify-content: space-between;
  238. align-items: center;
  239. width: 100%;
  240. margin-left: auto;
  241. .title {
  242. font-weight: bold;
  243. font-size: 36rpx;
  244. color: #333333;
  245. }
  246. .status {
  247. // margin-left: auto;
  248. color: rgba(138, 5, 84, 1);
  249. }
  250. }
  251. }
  252. </style>