index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <!-- 我的 -->
  3. <view class="safeDistance">
  4. <view style="padding: 20rpx;">
  5. <view class="card_mine">
  6. <view class="card_avatar" v-if="token != ''">
  7. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  8. <view class="card_user_title">
  9. <view class="mine_phone">{{userInfo.username}}</view>
  10. <view class="mine_phone">{{userInfo.nickName}}</view>
  11. </view>
  12. </view>
  13. <view class="card_avatar" v-else @click="login">
  14. <image class="mine_image" src="../../static/portrait.png" mode=""></image>
  15. <view class="mine_title">登录/注册</view>
  16. </view>
  17. </view>
  18. <view class="order_card" :style="{padding:(tableList.length > 5 ? '20rpx 20rpx 0rpx 20rpx' : '20rpx')}">
  19. <view class="order_head">
  20. <view class="head_left">我的运单</view>
  21. <!-- <view class="head_right">
  22. <view class="head_left">全部</view>
  23. <u-icon name="arrow-right"></u-icon>
  24. </view> -->
  25. </view>
  26. <view class="card_order">
  27. <u-scroll-list :indicator="tableList.length > 5 ? true : false" style="width: 100%;">
  28. <view :class="tableList.length > 5 ? 'card_majority' : 'card_minority'">
  29. <view class="item_order" v-for="(item,index) in tableList" :key="index"
  30. @click="goOrder(index)">
  31. <view class="card_tab_image center_in"
  32. :style="{background: item.bgColor,backgroundColor:item.colorBg}">
  33. <span class="iconfont icon_image" :class="item.icon"></span>
  34. </view>
  35. <view class="order_title">{{item.title}}</view>
  36. </view>
  37. </view>
  38. </u-scroll-list>
  39. </view>
  40. </view>
  41. <view class="card_system">
  42. <view class="space_between" @click="changePassword">
  43. <view style="display: flex;align-items: center;">
  44. <view class="card_edit_icon center_in">
  45. <u-icon name="setting" size="22" color="#ffffff"></u-icon>
  46. </view>
  47. <view class="option_title">修改密码</view>
  48. </view>
  49. <u-icon name="arrow-right" size="20"></u-icon>
  50. </view>
  51. </view>
  52. <view class="card_system">
  53. <view class="space_between" @click="logOut">
  54. <view style="display: flex;align-items: center;">
  55. <view class="card_icon_set center_in">
  56. <span class="iconfont icon-tuichudenglu"></span>
  57. </view>
  58. <view class="option_title">退出登录</view>
  59. </view>
  60. <u-icon name="arrow-right" size="20"></u-icon>
  61. </view>
  62. </view>
  63. <!-- <view class="card_system">
  64. <view class="space_between" @click="handleCheckVersion">
  65. <view style="display: flex;align-items: center;">
  66. <view class="card_icon_set center_in violet">
  67. <u-icon name="info" size="20" color="#ffffff"></u-icon>
  68. </view>
  69. <view class="option_title">版本更新</view>
  70. </view>
  71. <u-icon name="arrow-right" size="20"></u-icon>
  72. </view>
  73. </view> -->
  74. <!-- <view class="card_system">
  75. <view class="space_between" @click="bluetoothPrinting">
  76. <view style="display: flex;align-items: center;">
  77. <view class="card_edit_icon center_in">
  78. <u-icon name="setting" size="22" color="#ffffff"></u-icon>
  79. </view>
  80. <view class="option_title">蓝牙打印</view>
  81. </view>
  82. <u-icon name="arrow-right" size="20"></u-icon>
  83. </view>
  84. </view> -->
  85. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  86. @confirm="confirm"></u-modal>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. const ENV = require('../../.env.js')
  92. export default {
  93. props: {
  94. token: {
  95. type: String,
  96. default: () => '',
  97. },
  98. userInfo: {
  99. type: Object,
  100. default: () => {},
  101. },
  102. },
  103. data() {
  104. return {
  105. tableList: [],
  106. list: [{
  107. title: '全部',
  108. icon: 'icon-dingdan',
  109. colorBg: '#4bc7fc',
  110. bgColor: 'linear-gradient(to right, #84d4f6, #4bc7fc)',
  111. }, {
  112. title: '待装箱',
  113. icon: 'icon-bepacked',
  114. colorBg: '#db8e3e',
  115. bgColor: 'linear-gradient(to right, #f6d445, #fecb0e)',
  116. }, {
  117. title: '已装箱',
  118. icon: 'icon-boxed',
  119. colorBg: '#9ddd54',
  120. bgColor: 'linear-gradient(to right, #b9f377, #9ddd54)',
  121. }, {
  122. title: '未入库',
  123. icon: 'icon-chukudan',
  124. colorBg: '#fe880e',
  125. bgColor: 'linear-gradient(to right, #f69f45, #fe880e)',
  126. }, {
  127. title: '已入库',
  128. icon: 'icon-fankudengji',
  129. colorBg: '#fece56',
  130. bgColor: 'linear-gradient(to right, #f3d485, #fece56)',
  131. }, {
  132. title: '已出库',
  133. icon: 'icon-yidaoda',
  134. colorBg: '#9ddd54',
  135. bgColor: 'linear-gradient(to right, #b9f377, #9ddd54)',
  136. }],
  137. list1: [{
  138. title: '全部',
  139. icon: 'icon-dingdan',
  140. colorBg: '#4bc7fc',
  141. bgColor: 'linear-gradient(to right, #84d4f6, #4bc7fc)',
  142. }, {
  143. title: '待装箱',
  144. icon: 'icon-bepacked',
  145. colorBg: '#db8e3e',
  146. bgColor: 'linear-gradient(to right, #f6d445, #fecb0e)',
  147. }, {
  148. title: '已装箱',
  149. icon: 'icon-boxed',
  150. colorBg: '#9ddd54',
  151. bgColor: 'linear-gradient(to right, #b9f377, #9ddd54)',
  152. }, {
  153. title: '未装车',
  154. icon: 'icon-xiehuofei',
  155. colorBg: '#fe880e',
  156. bgColor: 'linear-gradient(to right, #f69f45, #fe880e)',
  157. }, {
  158. title: '已装车',
  159. icon: 'icon-yizhuangche',
  160. colorBg: '#fece56',
  161. bgColor: 'linear-gradient(to right, #f3d485, #fece56)',
  162. },
  163. {
  164. title: '已下车',
  165. icon: 'icon-xiehuo',
  166. colorBg: '#9ddd54',
  167. bgColor: 'linear-gradient(to right, #b9f377, #9ddd54)',
  168. },
  169. {
  170. title: '已签收',
  171. icon: 'icon-qianshou_fill',
  172. colorBg: '#1cc723',
  173. bgColor: 'linear-gradient(to right, #54ef5a, #1cc723)',
  174. }
  175. ],
  176. list2: [{
  177. title: '全部',
  178. icon: 'icon-dingdan',
  179. colorBg: '#4bc7fc',
  180. bgColor: 'linear-gradient(to right, #84d4f6, #4bc7fc)',
  181. }, {
  182. title: '未发货',
  183. icon: 'icon-weifahuo',
  184. colorBg: '#fe880e',
  185. bgColor: 'linear-gradient(to right, #f69f45, #fe880e)',
  186. }, {
  187. title: '已发货',
  188. icon: 'icon-yifahuo',
  189. colorBg: '#9ddd54',
  190. bgColor: 'linear-gradient(to right, #b9f377, #9ddd54)',
  191. }, {
  192. title: '已签收',
  193. icon: 'icon-yidaoda',
  194. colorBg: '#1cc723',
  195. bgColor: 'linear-gradient(to right, #54ef5a, #1cc723)',
  196. }],
  197. logoutShow: false,
  198. title: '确定退出?',
  199. content: '退出登录后将无法查看运单,重新登录后即可查看',
  200. innerVer: null,
  201. version: null,
  202. isCheckVersion: false
  203. }
  204. },
  205. created() {
  206. if (this.userInfo.userType == 'sys') {
  207. if (this.userInfo.type == 2) {
  208. // 仓管
  209. this.tableList = this.list
  210. } else if (this.userInfo.type == 3) {
  211. // 司机
  212. this.tableList = this.list1
  213. }
  214. } else {
  215. this.tableList = this.list2
  216. }
  217. },
  218. methods: {
  219. // 修改密码
  220. changePassword() {
  221. if (this.token) {
  222. uni.navigateTo({
  223. url: '/pages/mine/password'
  224. });
  225. } else {
  226. uni.$u.toast('请先登录')
  227. }
  228. },
  229. // 登录注册
  230. login() {
  231. uni.navigateTo({
  232. url: '/pages/login'
  233. });
  234. },
  235. // 订单页面
  236. goOrder(index) {
  237. if (this.token) {
  238. uni.navigateTo({
  239. url: '/pages/order/index?current=' + index
  240. });
  241. } else {
  242. uni.$u.toast('请先登录')
  243. }
  244. },
  245. // 退出登录
  246. logOut() {
  247. if (this.token) {
  248. this.logoutShow = true
  249. } else {
  250. uni.$u.toast('请先登录')
  251. }
  252. },
  253. // 版本更新
  254. versionUpdating() {
  255. // https: //coldlogistics.coldbaozhida.com/smartAppversion.json
  256. },
  257. handleCheckVersion() {
  258. let _this = this;
  259. // #ifdef APP-PLUS
  260. _this.isCheckVersion = true;
  261. plus.screen.lockOrientation('portrait-primary') // 竖屏锁定
  262. plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
  263. _this.innerVer = widgetInfo.version;
  264. _this.version = widgetInfo.versionCode;
  265. uni.request({
  266. url: ENV.APP_LINK_URL + '/smartAppversion.json?_t=' + new Date()
  267. .getTime(), //版本检测
  268. method: 'GET',
  269. header: {},
  270. success: (result) => {
  271. console.log(result.data.code, 14)
  272. if (result.data.code === 0) {
  273. setTimeout(() => {
  274. _this.isCheckVersion = false;
  275. }, 100);
  276. if (result.data.version - _this.version > 0) { // 如果最新版本大于现在已经安装的App的版本
  277. uni.showModal({
  278. title: "更新提示",
  279. content: "发现新版本,请确认下载更新?",
  280. success: (res) => {
  281. if (res.confirm) {
  282. uni.showLoading({
  283. title: '下载更新包中...'
  284. });
  285. uni.downloadFile({
  286. url: result.data.url,
  287. success: (downloadResult) => {
  288. uni.hideLoading();
  289. if (downloadResult
  290. .statusCode === 200
  291. ) {
  292. plus.runtime
  293. .install(
  294. downloadResult
  295. .tempFilePath, {
  296. force: true
  297. },
  298. function() {
  299. console
  300. .log(
  301. 'App安装成功!'
  302. );
  303. uni.showModal({
  304. title: 'App安装成功!',
  305. showCancel: false
  306. })
  307. plus.runtime
  308. .restart();
  309. },
  310. function(
  311. e) {
  312. console
  313. .log(
  314. 'App安装失败!'
  315. );
  316. })
  317. }
  318. }
  319. });
  320. }
  321. }
  322. })
  323. } else {
  324. uni.showModal({
  325. title: '当前已是最新版本',
  326. showCancel: false
  327. })
  328. }
  329. }
  330. }
  331. })
  332. })
  333. // #endif
  334. },
  335. // 蓝牙打印
  336. bluetoothPrinting() {
  337. uni.navigateTo({
  338. url: '/pages/mine/bluetooth'
  339. });
  340. },
  341. // 确定退出登录
  342. confirm() {
  343. this.$cache.removeToken()
  344. this.$cache.removeCache('userInfo')
  345. uni.redirectTo({
  346. url: '/pages/login'
  347. })
  348. },
  349. // 取消
  350. cancel() {
  351. this.logoutShow = false
  352. },
  353. }
  354. }
  355. </script>
  356. <style lang="scss">
  357. .card_user_title {
  358. display: flex;
  359. flex-direction: column;
  360. align-items: flex-start;
  361. }
  362. .card_mine {
  363. margin-top: 30rpx;
  364. padding: 0rpx 30rpx;
  365. background-color: #fff;
  366. border-radius: 20rpx;
  367. }
  368. .mine_image {
  369. width: 100rpx;
  370. height: 100rpx;
  371. border-radius: 50%;
  372. }
  373. .mine_phone {
  374. margin-left: 20rpx;
  375. font-size: 30rpx;
  376. }
  377. .mine_title {
  378. margin-left: 20rpx;
  379. font-size: 40rpx;
  380. font-weight: bold;
  381. }
  382. .card_avatar {
  383. display: flex;
  384. align-items: center;
  385. padding-top: 30rpx;
  386. padding-bottom: 30rpx;
  387. }
  388. .order_card {
  389. margin-top: 20rpx;
  390. background-color: #fff;
  391. padding: 20rpx;
  392. border-radius: 20rpx;
  393. }
  394. .order_head {
  395. position: relative;
  396. display: flex;
  397. align-items: center;
  398. justify-content: space-between;
  399. padding-bottom: 20rpx;
  400. }
  401. .order_head:before {
  402. content: " ";
  403. position: absolute;
  404. left: 0;
  405. bottom: 0;
  406. width: 100%;
  407. height: 1px;
  408. border-top: 1px solid #e7e6e4;
  409. -webkit-transform-origin: 0 0;
  410. transform-origin: 0 0;
  411. -webkit-transform: scaleY(0.5);
  412. transform: scaleY(0.5);
  413. }
  414. .head_left {
  415. margin-right: 10rpx;
  416. }
  417. .head_right {
  418. display: flex;
  419. align-items: center;
  420. }
  421. .card_order {
  422. margin-top: 30rpx;
  423. display: flex;
  424. justify-content: space-around;
  425. }
  426. .item_order {
  427. width: 20%;
  428. flex: none;
  429. display: flex;
  430. flex-direction: column;
  431. align-items: center;
  432. }
  433. .card_minority {
  434. width: 100%;
  435. display: flex;
  436. justify-content: space-around;
  437. }
  438. .card_majority {
  439. width: 100%;
  440. display: flex;
  441. }
  442. .card_tab_image {
  443. width: 80rpx;
  444. height: 80rpx;
  445. border-radius: 50%;
  446. }
  447. .order_title {
  448. margin-top: 6rpx;
  449. font-size: 25rpx;
  450. }
  451. .icon_image {
  452. color: #fff;
  453. font-size: 37rpx;
  454. }
  455. .card_system {
  456. margin-top: 20rpx;
  457. background-color: #fff;
  458. padding: 30rpx 20rpx;
  459. border-radius: 20rpx;
  460. }
  461. .card_mine_option {
  462. position: relative;
  463. margin: 20rpx 0rpx;
  464. padding-bottom: 30rpx;
  465. }
  466. .option_title {
  467. margin-left: 10rpx;
  468. font-size: 28rpx;
  469. font-weight: 500;
  470. }
  471. .card_edit_icon {
  472. width: 55rpx;
  473. height: 55rpx;
  474. border-radius: 50%;
  475. background-color: #ff9900;
  476. }
  477. .card_icon_set {
  478. width: 55rpx;
  479. height: 55rpx;
  480. border-radius: 50%;
  481. background-color: #fa3534;
  482. span {
  483. color: #fff;
  484. font-size: 40rpx;
  485. }
  486. }
  487. .violet {
  488. background-color: #fe654a !important;
  489. }
  490. </style>