index.vue 9.7 KB

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