index.vue 6.5 KB

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