index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="order-detail" :class="{ 'fixed-bottom-2': type == 2 }">
  3. <scroll-view class="scroller" :scroll-into-view="toView" scroll-y="true" scroll-with-animation="true">
  4. <view class="flex flex-a-c flex-j-b bg-white bind-audit mb-16">
  5. <text>绑定审核员</text>
  6. <text class="text-center flex-1">{{
  7. orderDetail.auditUserName || selectedAuditor?.userName || ""
  8. }}</text>
  9. <text @click="showAuditorSelector = true" class="color-primary">绑定</text>
  10. </view>
  11. <OrderInfo :detail="orderDetail" @refresh="getOrderDetail" />
  12. <UserInfoCard :detail="orderDetail" />
  13. <view class="mt-16" style="padding: 0 6rpx">
  14. <u-subsection
  15. :list="list"
  16. mode="subsection"
  17. :current="current"
  18. @change="handleSectionChange"
  19. ></u-subsection>
  20. <BookInfo
  21. v-if="current == 0"
  22. :bookList="orderDetail.detailVoList"
  23. :detail="orderDetail"
  24. @get-all-firstLetter="onGetAllFirstLetter"
  25. />
  26. <LogisticsTimeline v-if="current == 1" :list="orderDetail.trackingVoList" />
  27. <FileInfo v-if="current == 2" :orderId="orderDetail.orderId" />
  28. </view>
  29. </scroll-view>
  30. <view class="fixed-left">
  31. <view class="bind-code common-bg" style="margin-bottom: 30px; padding: 20rpx" @click="handleBindCode"
  32. >绑码
  33. </view>
  34. <view class="common-bg flex flex-a-c flex-j-c flex-d">
  35. <view class="book-status-item" @click="scrollToView('good')">良好</view>
  36. <view class="book-status-item item-center" @click="scrollToView('average')">一般</view>
  37. <view class="book-status-item" @click="scrollToView('poor')">极差</view>
  38. </view>
  39. </view>
  40. <view class="fixed-right">
  41. <view class="letter-bg flex flex-a-c flex-j-c flex-d">
  42. <view class="letter-item"
  43. ><u-icon name="arrow-up-fill" size="20" color="#ffffff" @click="scrollToTop"></u-icon
  44. ></view>
  45. <view class="letter-item" v-for="item in allLetters" @click="scrollToView(item)">{{ item }}</view>
  46. </view>
  47. </view>
  48. <view class="common-bg fixed-bottom" v-if="type != 2">
  49. <u-button type="warning" size="large" v-if="orderDetail.status == 5" @click="handleLogisticsConfirm"
  50. >物流签收</u-button
  51. >
  52. <u-button type="primary" size="large" v-if="orderDetail.status == 6" @click="handleConfirm"
  53. >确认收货</u-button
  54. >
  55. <template v-if="orderDetail.status == 8 || orderDetail.status == 9 || orderDetail.status == 10">
  56. <u-button type="warning" size="large" @click="handleScanCode">扫码</u-button>
  57. <u-button type="primary" size="large" @click="handleComplete">完成</u-button>
  58. </template>
  59. </view>
  60. <AuditorSelector
  61. :show="showAuditorSelector"
  62. @update:show="showAuditorSelector = $event"
  63. @auditor-selected="handleAuditorSelected"
  64. />
  65. </view>
  66. </template>
  67. <script setup>
  68. import { ref } from "vue";
  69. import { onLoad, onShow } from "@dcloudio/uni-app";
  70. import AuditorSelector from "./components/AuditorSelector.vue";
  71. import OrderInfo from "./components/OrderInfo.vue";
  72. import UserInfoCard from "./components/UserInfoCard.vue";
  73. import LogisticsTimeline from "../express/components/LogisticsTimeline.vue";
  74. import BookInfo from "./components/BookInfo.vue";
  75. import FileInfo from "./components/FileInfo.vue";
  76. const showAuditorSelector = ref(false);
  77. const selectedAuditor = ref({});
  78. const handleAuditorSelected = (auditor) => {
  79. selectedAuditor.value = auditor;
  80. orderDetail.value.auditUserId = auditor.userId;
  81. orderDetail.value.auditUserName = auditor.userName;
  82. uni.setStorageSync("checkUserInfo", {
  83. userName: auditor.userName,
  84. userId: auditor.userId,
  85. });
  86. };
  87. //点击滚动的位置
  88. const toView = ref("");
  89. function scrollToView(to) {
  90. toView.value = to;
  91. uni.pageScrollTo({
  92. selector: "#" + to,
  93. duration: 200,
  94. });
  95. }
  96. //回到顶部
  97. function scrollToTop() {
  98. uni.pageScrollTo({
  99. top: 0,
  100. duration: 200,
  101. });
  102. }
  103. //绑码
  104. function handleBindCode() {
  105. uni.$u.toast("暂无开发");
  106. }
  107. const list = ref(["图书清单", "物流信息", "上传附件"]);
  108. const current = ref(0);
  109. const handleSectionChange = (index) => {
  110. current.value = index;
  111. };
  112. //监听书籍的首字母
  113. const allLetters = ref([]);
  114. function onGetAllFirstLetter(data) {
  115. allLetters.value = data;
  116. }
  117. //物流签收 /app/orderinfo/signLogistics
  118. function handleLogisticsConfirm() {
  119. uni.showModal({
  120. title: "提示",
  121. content: "是否确认物流签收?",
  122. success: (res) => {
  123. if (res.confirm) {
  124. uni.showLoading({ title: "加载中...", mask: true });
  125. uni.$u.http
  126. .post("/app/orderinfo/signLogistics", {
  127. searchType: 1,
  128. search: orderDetail.value.orderId,
  129. })
  130. .then((res) => {
  131. if (res.code == 200) {
  132. uni.showToast({ title: "签收成功", icon: "none" });
  133. uni.$u.ttsModule.speak("签收成功");
  134. uni.navigateBack();
  135. }
  136. })
  137. .finally(() => {
  138. uni.hideLoading();
  139. });
  140. }
  141. },
  142. });
  143. }
  144. //确认收货 /app/orderinfo/confirmOrder
  145. function handleConfirm() {
  146. uni.showLoading({ title: "加载中...", mask: true });
  147. uni.$u.http
  148. .post("/app/orderinfo/confirmOrder", {
  149. searchType: 1,
  150. search: orderDetail.value.orderId,
  151. })
  152. .then((res) => {
  153. if (res.code == 200) {
  154. uni.showToast({ title: "确认收货成功", icon: "none" });
  155. uni.$u.ttsModule.speak("确认收货成功");
  156. getOrderDetail();
  157. }
  158. })
  159. .finally(() => {
  160. uni.hideLoading();
  161. });
  162. }
  163. //完成
  164. function handleComplete() {
  165. let bookList = orderDetail.value.detailVoList;
  166. let bool = bookList.some((item) => item.auditCommentList?.length < item.num);
  167. if (bool) {
  168. let text = "还有未审核的书";
  169. uni.$u.toast(text);
  170. uni.$u.ttsModule.speak(text);
  171. return;
  172. } else {
  173. uni.$u.http
  174. .post("/app/orderinfo/checkOrderFinish", {
  175. checkUserId: orderDetail.value.auditUserId,
  176. orderId: orderDetail.value.orderId,
  177. })
  178. .then((res) => {
  179. if (res.code == 200) {
  180. uni.showToast({ title: "审核完成", icon: "none" });
  181. uni.$u.ttsModule.speak("审核完成");
  182. uni.navigateBack();
  183. }
  184. });
  185. }
  186. }
  187. const orderDetail = ref({ status: 0 });
  188. //获取订单详情
  189. function getOrderDetail() {
  190. if (!orderId.value) return;
  191. uni.showLoading({
  192. title: "加载中...",
  193. mask: true,
  194. });
  195. uni.$u.http
  196. .get("/app/orderinfo/getOrderInfoForCheck", {
  197. params: {
  198. searchType: 1,
  199. search: orderId.value,
  200. },
  201. })
  202. .then((res) => {
  203. if (res.code == 200) {
  204. orderDetail.value = res.data;
  205. getCheckUserInfo();
  206. if (res.data.auditUserId) {
  207. let auditUserInfo = {
  208. userName: res.data.auditUserName,
  209. userId: res.data.auditUserId,
  210. };
  211. uni.setStorageSync("checkUserInfo", auditUserInfo);
  212. } else {
  213. let userInfo = uni.getStorageSync("checkUserInfo");
  214. orderDetail.value.auditUserName = userInfo.userName;
  215. orderDetail.value.auditUserId = userInfo.userId;
  216. }
  217. if (isOnLoad.value) {
  218. if (res.data.manageRemark.length > 0 && res.data.status < 10) {
  219. uni.$u.ttsModule.speak("此订单有备注信息,请注意查看");
  220. }
  221. if (res.data.warnArea && res.data.warnArea.length > 0) {
  222. let text = `此订单来源于${res.data.warnArea}`;
  223. uni.$u.ttsModule.speak(text);
  224. }
  225. isOnLoad.value = false;
  226. }
  227. } else {
  228. uni.$u.toast(res.msg);
  229. }
  230. })
  231. .finally(() => {
  232. uni.hideLoading();
  233. });
  234. }
  235. //获取上一次绑定的审核员信息
  236. function getCheckUserInfo() {
  237. uni.$u.http.get("/app/orderinfo/getCheckUser").then((res) => {
  238. if (res.code == 200) {
  239. let userInfo = res.data;
  240. orderDetail.value.auditUserName = userInfo.userName;
  241. orderDetail.value.auditUserId = userInfo.userId;
  242. uni.setStorageSync("checkUserInfo", {
  243. userName: userInfo.userName,
  244. userId: userInfo.userId,
  245. });
  246. }
  247. });
  248. }
  249. //isbn正则校验是否符合
  250. function checkIsbn(isbn) {
  251. const isbn13Regex = /^(?:97[89]-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d)$/;
  252. if (isbn13Regex.test(isbn)) {
  253. return true;
  254. }
  255. return false;
  256. }
  257. //扫码之后的逻辑
  258. function handleScan(isbn) {
  259. if (!checkIsbn(isbn)) {
  260. let text = `不是正确的ISBN码`;
  261. uni.$u.ttsModule.speak(text);
  262. return;
  263. }
  264. if (orderDetail.value.status >= 10) {
  265. uni.$u.ttsModule.speak("订单已审核完成");
  266. return;
  267. }
  268. let isbns = orderDetail.value.detailVoList.map((item) => item.isbn);
  269. if (isbns.includes(isbn)) {
  270. let book = orderDetail.value.detailVoList.find((item) => item.isbn == isbn);
  271. //扫描到套装书
  272. if (book.suit == 1) {
  273. let text = `${isbn}请注意套装书是否齐全`;
  274. uni.$u.ttsModule.speak(text);
  275. }
  276. //扫描到需要取出的书
  277. if (book.bookWarn == 1) {
  278. let text = `请注意${isbn}需要取出`;
  279. uni.$u.ttsModule.speak(text);
  280. }
  281. uni.navigateTo({
  282. url: `/pages/index/detail/book-audit?isbn=${isbn}&orderId=${orderDetail.value.orderId}`,
  283. });
  284. uni.setStorageSync("auditBook", book);
  285. uni.setStorageSync("orderDetail", orderDetail.value);
  286. } else {
  287. let text = `此订单中不存在${isbn}这本书 `;
  288. uni.$u.ttsModule.speak(text);
  289. }
  290. }
  291. //扫码
  292. function handleScanCode() {
  293. uni.scanCode({
  294. success: (res) => {
  295. res.result && handleScan(res.result);
  296. },
  297. });
  298. }
  299. const orderId = ref("");
  300. const isOnLoad = ref(false);
  301. // 1 表示到货审核 2 表示查看订单
  302. const type = ref(1);
  303. onLoad((option) => {
  304. orderId.value = option.id;
  305. getOrderDetail();
  306. isOnLoad.value = true;
  307. type.value = option.type || 1;
  308. uni.removeStorageSync("scannedBooks");
  309. // #ifdef APP-PLUS
  310. uni.$u.useGlobalEvent((e) => {
  311. if (e.barcode) {
  312. handleScan(e.barcode);
  313. }
  314. });
  315. // #endif
  316. });
  317. onShow(() => {
  318. uni.$u.updateActivePageOnShow();
  319. getOrderDetail();
  320. });
  321. </script>
  322. <style>
  323. page {
  324. background-color: #f5f5f5;
  325. }
  326. </style>
  327. <style lang="scss" scoped>
  328. .order-detail {
  329. font-size: 30rpx;
  330. padding-bottom: 140rpx;
  331. position: relative;
  332. &.fixed-bottom-2 {
  333. padding-bottom: 30rpx;
  334. }
  335. .bind-audit {
  336. padding: 20rpx 30rpx;
  337. border-bottom: 1px solid #e5e5e5;
  338. }
  339. .fixed-left {
  340. position: fixed;
  341. left: 0;
  342. top: 11%;
  343. width: 100rpx;
  344. .common-bg {
  345. background-color: rgba(34, 172, 56, 0.7);
  346. border-radius: 0 30rpx 30rpx 0;
  347. font-weight: 500;
  348. color: #ffffff;
  349. }
  350. .book-status-item {
  351. padding: 20rpx;
  352. border-top: 1rpx solid #ffffff;
  353. border-bottom: 1rpx solid #ffffff;
  354. }
  355. }
  356. .fixed-right {
  357. position: fixed;
  358. right: 0;
  359. top: 12%;
  360. width: 70rpx;
  361. .letter-bg {
  362. background-color: rgba(34, 172, 56, 0.7);
  363. border-radius: 10rpx 0 0 10rpx;
  364. font-weight: 500;
  365. color: #ffffff;
  366. padding: 12rpx 0;
  367. padding-bottom: 6rpx;
  368. }
  369. .letter-item {
  370. padding-bottom: 12rpx;
  371. }
  372. }
  373. }
  374. </style>