index.vue 12 KB

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