index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <!-- 订单页面 -->
  3. <view>
  4. <u-navbar title="我的运单" autoBack placeholder></u-navbar>
  5. <view class="tab_order" :style="{top:height + 86 + 'rpx'}">
  6. <u-tabs :list="tableList" lineColor="#333333" lineWidth="40" :scrollable="scrollable" :current="current"
  7. @change="tabClick"></u-tabs>
  8. </view>
  9. <view class="card_order_mangement" v-if="orderList.length > 0">
  10. <x-orderManagement :orderList="orderList" :userInfo="userInfo" @sendmail="sendmail"
  11. :key="keyId"></x-orderManagement>
  12. <view style="width: 50%;">
  13. <u-loadmore :status="loadStatus" :key="Math.random()" />
  14. <!-- <u-divider v-if="loadingMore" :text="loading"></u-divider> -->
  15. </view>
  16. </view>
  17. <u-empty mode="order" marginTop="50" v-else></u-empty>
  18. <u-popup :show="emailShow" mode="center" round="5" closeable @close="close">
  19. <view style="padding: 30rpx;">
  20. <view style="margin-top: 20rpx;width: 600rpx;">
  21. <view class="email_title" style="margin-bottom: 10rpx;">运单号:{{waybillNo}}</view>
  22. <view class="card_email">
  23. <span class="email_title">邮箱地址:</span>
  24. <view style="margin-top: 20rpx;">
  25. <u--input v-model="email" placeholder="请输入邮箱" border="surround"></u--input>
  26. </view>
  27. </view>
  28. </view>
  29. <view style="margin-top: 20rpx;">
  30. <u-button type="primary" :loading="sendLoading" text="发送" @click="confirm"></u-button>
  31. </view>
  32. </view>
  33. </u-popup>
  34. </view>
  35. </template>
  36. <script>
  37. import index from '../../uview-ui'
  38. export default {
  39. data() {
  40. return {
  41. tableList: [],
  42. list: [{
  43. name: '全部',
  44. }, {
  45. id: 9,
  46. name: '待装箱',
  47. }, {
  48. id: 10,
  49. name: '已装箱',
  50. }, {
  51. id: 11,
  52. name: '已出箱',
  53. }, {
  54. id: 3,
  55. name: '未入库',
  56. }, {
  57. id: 5,
  58. name: '已入库'
  59. }, {
  60. id: 7,
  61. name: '已出库'
  62. }, {
  63. id: 8,
  64. name: '已签收'
  65. }],
  66. list1: [{
  67. name: '全部',
  68. }, {
  69. id: 9,
  70. name: '待装箱',
  71. }, {
  72. id: 10,
  73. name: '已装箱',
  74. }, {
  75. id: 11,
  76. name: '已出箱',
  77. }, {
  78. id: 2,
  79. name: '未装车',
  80. }, {
  81. id: 4,
  82. name: '已装车'
  83. }, {
  84. id: 6,
  85. name: '已下车'
  86. }, {
  87. id: 8,
  88. name: '已签收'
  89. }],
  90. list2: [{
  91. name: '全部',
  92. }, {
  93. id: 1,
  94. name: '未发货',
  95. }, {
  96. id: 2,
  97. name: '已发货'
  98. }, {
  99. id: 3,
  100. name: '已签收'
  101. }],
  102. current: 0,
  103. userInfo: {},
  104. orderList: [],
  105. pageSize: 10,
  106. currentPage: 1,
  107. loadingMore: true,
  108. loading: '加载中',
  109. status: null,
  110. scrollable: false,
  111. emailShow: false,
  112. email: '',
  113. humidityFlag: false,
  114. waybillNo: '',
  115. sendLoading: false,
  116. loadStatus: 'loadmore', //loading 、nomore
  117. keyId: 0,
  118. height: 0,
  119. }
  120. },
  121. onReachBottom() {
  122. if (!this.loadingMore) {
  123. if (this.userInfo.userType == 'sys') {
  124. this.getList()
  125. } else {
  126. this.getUserList()
  127. }
  128. }
  129. },
  130. onLoad(value) {
  131. const arr = uni.getSystemInfoSync().statusBarHeight
  132. this.height = arr
  133. if (value.current) {
  134. this.current = Number(value.current)
  135. }
  136. var userInfo = this.$cache.getCache('userInfo')
  137. // console.log(userInfo, 25)
  138. this.userInfo = userInfo
  139. if (userInfo.userType == 'sys') {
  140. if (userInfo.type == 2) {
  141. // 仓管
  142. this.scrollable = true
  143. this.tableList = this.list
  144. let statusType = ''
  145. if (this.current != 0 || this.current) {
  146. statusType = this.tableList[this.current].id
  147. }
  148. this.status = statusType
  149. this.getList()
  150. } else if (userInfo.type == 3) {
  151. // 司机
  152. this.scrollable = true
  153. this.tableList = this.list1
  154. let statusType = ''
  155. if (this.current != 0 || this.current) {
  156. statusType = this.tableList[this.current].id
  157. }
  158. this.status = statusType
  159. this.getList()
  160. }
  161. } else {
  162. this.tableList = this.list2
  163. this.status = this.tableList[this.current].id
  164. this.getUserList()
  165. }
  166. },
  167. methods: {
  168. // 获取司机和仓管订单列表
  169. getList() {
  170. this.loadStatus = 'loading'
  171. this.loadingMore = true;
  172. this.$api.get('/api/waybill/applet', {
  173. page: this.currentPage,
  174. pageSize: this.pageSize,
  175. status: this.status,
  176. }).then(res => {
  177. if (res.code == 200) {
  178. const data = res.data.list
  179. if (this.loadingMore == true && data) {
  180. this.orderList = this.orderList.concat(data);
  181. }
  182. if (data.length < this.pageSize) {
  183. this.loadingMore = true
  184. this.loading = '没有更多了'
  185. this.loadStatus = 'nomore'
  186. } else {
  187. this.loading = '加载中'
  188. this.loadStatus = 'loading'
  189. this.loadingMore = false
  190. this.currentPage++
  191. }
  192. this.$forceUpdate()
  193. }
  194. }).catch(() => {
  195. this.loadingMore = true
  196. this.loadStatus = 'nomore'
  197. })
  198. },
  199. // 获取用户订单列表
  200. getUserList() {
  201. this.loadStatus = 'loading'
  202. this.loadingMore = true;
  203. this.$api.get('/api/waybill/customer', {
  204. page: this.currentPage,
  205. pageSize: this.pageSize,
  206. status: this.status,
  207. }).then(res => {
  208. if (res.code == 200) {
  209. const data = res.data.list
  210. if (this.loadingMore == true && data) {
  211. this.orderList = this.orderList.concat(data);
  212. }
  213. if (data.length < this.pageSize) {
  214. this.loadingMore = true
  215. this.loading = '没有更多了'
  216. this.loadStatus = 'nomore'
  217. } else {
  218. this.loading = '加载中'
  219. this.loadStatus = 'loading'
  220. this.loadingMore = false
  221. this.currentPage++
  222. }
  223. this.$forceUpdate()
  224. }
  225. }).catch(() => {
  226. this.loadingMore = true
  227. this.loadStatus = 'nomore'
  228. })
  229. },
  230. // tab订单
  231. tabClick(row) {
  232. this.loadStatus = 'loading'
  233. this.keyId = row.index
  234. this.loadingMore = true
  235. this.currentPage = 1
  236. this.orderList = []
  237. if (this.userInfo.userType == 'sys') {
  238. this.status = row.id
  239. this.getList()
  240. } else {
  241. this.status = row.id
  242. this.getUserList()
  243. }
  244. },
  245. // 发送邮件
  246. sendmail(value) {
  247. this.emailShow = true
  248. this.waybillNo = value.waybillNo
  249. },
  250. confirm() {
  251. if (this.email) {
  252. let flag = validateEmail(this.email)
  253. if (flag) {
  254. if (!this.sendLoading) {
  255. this.sendLoading = true
  256. let arrTo = []
  257. arrTo.push(this.email)
  258. this.$api.post('/api/waybill/send-mail', {
  259. waybillNo: this.waybillNo,
  260. humidityShow: this.humidityFlag,
  261. to: arrTo,
  262. }).then(res => {
  263. if (res.code == 200) {
  264. uni.$u.toast(res.msg)
  265. this.email = ''
  266. this.emailShow = false
  267. }
  268. this.sendLoading = false
  269. }).catch(() => {
  270. this.sendLoading = false
  271. })
  272. }
  273. } else {
  274. uni.$u.toast('邮箱格式错误')
  275. }
  276. } else {
  277. uni.$u.toast('请输入邮箱')
  278. }
  279. // 如果邮箱格式正确,输出 true,否则输出 false
  280. function validateEmail(email) {
  281. const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
  282. return emailRegex.test(email);
  283. }
  284. },
  285. close() {
  286. this.emailShow = false
  287. this.email = ''
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss">
  293. .tab_order {
  294. position: sticky;
  295. z-index: 10;
  296. background-color: #fff;
  297. }
  298. .card_order_mangement {
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. }
  303. .card_email {}
  304. .email_title {
  305. font-size: 32rpx;
  306. }
  307. </style>