index.vue 6.7 KB

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