index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <template v-if="isRequest">
  5. <view class="ws-header">
  6. <!-- 用户信息 -->
  7. <view class="user-info">
  8. <image
  9. class="user_default"
  10. v-if="!hasLogin && isRequest"
  11. :src="StaticUrl + 'icon-default-avatar.png'"
  12. mode="widthFix"
  13. ></image>
  14. <image class="user_default" v-else :src="userInfo.headImgUrl" mode="widthFix"></image>
  15. <view class="user-login" v-if="!hasLogin && isRequest" @click="navigator('/pages/login/login')"
  16. >登录</view
  17. >
  18. <view class="user-text" v-else> {{ userIdentity == 1 ? userInfo.nickName : userInfo.name }} </view>
  19. </view>
  20. <!-- 背景图 -->
  21. <image class="user-bg" :src="StaticUrl + 'icon-user-bg@2x.png'" mode="widthFix"></image>
  22. </view>
  23. <!-- 机构信息END -->
  24. <!-- 订单状态区域 -->
  25. <view class="order-wrap">
  26. <view class="more">
  27. <text class="title">我的订单</text>
  28. <view @click="OrderNavigator(0)">
  29. <text class="more-right">全部订单</text> <text class="iconfont icon-chakangengduo"></text>
  30. </view>
  31. </view>
  32. <view class="line"></view>
  33. <!-- 菜单选项 -->
  34. <view class="order-nav">
  35. <view class="order-nav-item" @click="OrderNavigator(1)">
  36. <image :src="StaticUrl + 'icon-order-1@2x.png'" mode="widthFix"></image> <text>待付款</text>
  37. <view class="tui-badge tui-badge-box" v-if="hasLogin && paymentCount > 0">
  38. <tui-badge :scaleRatio="0.8" type="danger">{{ paymentCount | countNum }}</tui-badge>
  39. </view>
  40. </view>
  41. <view class="order-nav-item" @click="OrderNavigator(2)">
  42. <image :src="StaticUrl + 'icon-order-2@2x.png'" mode="widthFix"></image> <text>待发货</text>
  43. <view class="tui-badge tui-badge-box" v-if="hasLogin && waitShipmentsCount > 0">
  44. <tui-badge :scaleRatio="0.8" type="danger">{{ waitShipmentsCount | countNum }}</tui-badge>
  45. </view>
  46. </view>
  47. <view class="order-nav-item" @click="OrderNavigator(3)">
  48. <image :src="StaticUrl + 'icon-order-3@2x.png'" mode="widthFix"></image> <text>已发货</text>
  49. <view class="tui-badge tui-badge-box" v-if="hasLogin && shipmentsCount > 0">
  50. <tui-badge :scaleRatio="0.8" type="danger">{{ shipmentsCount | countNum }}</tui-badge>
  51. </view>
  52. </view>
  53. <view class="order-nav-item" @click="OrderNavigator(3)">
  54. <image :src="StaticUrl + 'icon-order-4@2x.png'" mode="widthFix"></image> <text>退货/款</text>
  55. <view class="tui-badge tui-badge-box" v-if="hasLogin && salesReturnCount > 0">
  56. <tui-badge :scaleRatio="0.8" type="danger">{{ salesReturnCount | countNum }}</tui-badge>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 订单状态区域END -->
  62. <!-- 菜单导航区域 -->
  63. <view class="place-menu-conten clearfix">
  64. <view class="place-menu-cell" @click="navigator('/pages/user/activity/coupon-list')">
  65. <view class="place-left">
  66. <image class="place-menu-icon" :src="StaticUrl + 'icon-coupon.png'" mode=""></image>
  67. <text class="place-menu-title">优惠券</text>
  68. <text class="coupons-count">6</text>
  69. </view>
  70. <text class="iconfont icon-chakangengduo"></text>
  71. </view>
  72. <view
  73. class="place-menu-cell"
  74. @click="navigator('/pages/user/activity/activity-list')"
  75. v-if="userIdentity == 2"
  76. >
  77. <view class="place-left">
  78. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-h@2x.png'" mode=""></image>
  79. <text class="place-menu-title">活动专区</text>
  80. </view>
  81. <text class="iconfont icon-chakangengduo"></text>
  82. </view>
  83. <view class="place-menu-cell" @click="navigator('/pages/user/address/address')">
  84. <view class="place-left">
  85. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-d@2x.png'" mode=""></image>
  86. <text class="place-menu-title">收货地址</text>
  87. </view>
  88. <text class="iconfont icon-chakangengduo"></text>
  89. </view>
  90. <button class="place-menu-cell last" open-type="contact" @bindcontact="handleContact">
  91. <view class="place-left">
  92. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-c@2x.png'" mode=""></image>
  93. <text class="place-menu-title">在线客服</text>
  94. </view>
  95. <text class="iconfont icon-chakangengduo"></text>
  96. </button>
  97. </view>
  98. <!-- 菜单导航区域END -->
  99. <!-- 底部 -->
  100. <view class="user-support" :class="userIdentity == 2 ? 'top' : ''">
  101. <image class="user-support-image" :src="StaticUrl + 'icon-logo@1x.png'" mode=""></image>
  102. <view class="user-support-text">采美365网提供商品技术服务</view>
  103. </view>
  104. </template>
  105. </view>
  106. </template>
  107. <script>
  108. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  109. import { mapGetters, mapMutations, mapActions } from 'vuex'
  110. import authorize from '@/common/authorize.js'
  111. import wxLogin from '@/services/wxLogin.js'
  112. export default {
  113. components: {
  114. nutBadge
  115. },
  116. data() {
  117. return {
  118. StaticUrl: this.$Static,
  119. CustomBar: this.CustomBar, // 顶部导航栏高度
  120. isRequest: true,
  121. paymentCount: 0, //待付款角标
  122. waitShipmentsCount: 0, //待收货角标
  123. shipmentsCount: 0, //已发货角标
  124. salesReturnCount: 0 //退货/款角标
  125. }
  126. },
  127. computed: {
  128. ...mapGetters(['hasLogin', 'userInfo', 'userId', 'userIdentity'])
  129. },
  130. filters: {
  131. countNum(value) {
  132. return value > 99 ? '99+' : value
  133. }
  134. },
  135. onShow() {
  136. if (this.hasLogin) {
  137. this.getCartNumber()
  138. this.GetUserInfoPersonal()
  139. }
  140. },
  141. methods: {
  142. ...mapMutations('app', ['login', 'logout']),
  143. ...mapActions('cart', ['getCartNumber']),
  144. //初始化个人中心数据
  145. GetUserInfoPersonal() {
  146. this.UserService.GetUserOrderTotal({
  147. userId: this.userId
  148. })
  149. .then(response => {
  150. const data = response.data
  151. this.paymentCount = data.paymentCount //待付款
  152. this.waitShipmentsCount = data.waitShipmentsCount //待收货
  153. this.shipmentsCount = data.shipmentsCount //已发货
  154. this.salesReturnCount = data.salesReturnCount //退货/款
  155. })
  156. .catch(error => {
  157. this.$util.msg(error.msg, 2000)
  158. })
  159. },
  160. handleContact(e) {
  161. //客服
  162. console.log(e.detail.path)
  163. console.log(e.detail.query)
  164. },
  165. OrderNavigator(state) {
  166. // 栏目跳转
  167. if (this.hasLogin) {
  168. if (this.userIdentity == 2) {
  169. this.$api.navigateTo(`/pages/user/order/order-list-retail?state=${state}`)
  170. } else {
  171. this.$api.navigateTo(`/pages/user/order/order-list?state=${state}`)
  172. }
  173. } else {
  174. this.$api.navigateTo('/pages/login/login')
  175. }
  176. },
  177. navigator(url) {
  178. if (this.hasLogin) {
  179. this.$api.navigateTo(url)
  180. } else {
  181. this.$api.navigateTo('/pages/login/login')
  182. }
  183. }
  184. },
  185. onPullDownRefresh() {
  186. //下拉刷新
  187. if (this.hasLogin) {
  188. this.GetUserInfo()
  189. setTimeout(() => {
  190. uni.stopPullDownRefresh()
  191. }, 2000)
  192. } else {
  193. uni.stopPullDownRefresh()
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. @import '@/uni.scss';
  200. .container {
  201. box-sizing: border-box;
  202. background: #f7f7f7;
  203. }
  204. // 用户登录信息区域
  205. .ws-title {
  206. width: 100%;
  207. position: fixed;
  208. top: 0;
  209. left: 0;
  210. font-size: 34rpx;
  211. text-align: center;
  212. }
  213. .ws-header {
  214. position: relative;
  215. height: 280rpx;
  216. .user-info {
  217. position: absolute;
  218. z-index: 10;
  219. width: 750rpx;
  220. height: 280rpx;
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. justify-content: center;
  225. .user_default {
  226. display: block;
  227. width: 120rpx;
  228. height: 120rpx;
  229. border-radius: 50%;
  230. }
  231. }
  232. // 登录按钮
  233. .user-login {
  234. width: 184rpx;
  235. height: 56rpx;
  236. margin-top: 25rpx;
  237. border-radius: 28rpx;
  238. background: #ffffff;
  239. line-height: 56rpx;
  240. text-align: center;
  241. color: $color-system;
  242. font-size: $font-size-28;
  243. }
  244. // 公司名
  245. .user-text {
  246. width: 446rpx;
  247. margin-top: 25rpx;
  248. color: #fff;
  249. font-size: 28rpx;
  250. line-height: 40rpx;
  251. text-align: center;
  252. white-space: nowrap;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. }
  256. .user-bg {
  257. width: 100%;
  258. }
  259. }
  260. .more {
  261. width: 750rpx;
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. padding: 23rpx 25rpx;
  266. box-sizing: border-box;
  267. background: #fff;
  268. .more-right {
  269. font-size: 26rpx;
  270. line-height: 37rpx;
  271. margin-right: 10rpx;
  272. }
  273. .title {
  274. font-size: 32rpx;
  275. line-height: 45rpx;
  276. color: #333333;
  277. }
  278. .iconfont {
  279. font-size: 20rpx;
  280. vertical-align: middle;
  281. }
  282. }
  283. .order-wrap {
  284. background: #fff;
  285. .line {
  286. width: 702rpx;
  287. height: 1px;
  288. margin: 0 auto;
  289. background: #f0f0f0;
  290. }
  291. .order-nav {
  292. display: flex;
  293. justify-content: space-evenly;
  294. align-items: center;
  295. padding: 40rpx 0;
  296. .order-nav-item {
  297. position: relative;
  298. display: flex;
  299. align-items: center;
  300. flex-direction: column;
  301. image {
  302. width: 64rpx;
  303. height: 64rpx;
  304. }
  305. text {
  306. font-size: 26rpx;
  307. line-height: 37rpx;
  308. margin-top: 8rpx;
  309. }
  310. .tui-badge {
  311. position: absolute;
  312. top: -15rpx;
  313. right: -25rpx;
  314. z-index: 999;
  315. }
  316. }
  317. }
  318. }
  319. .place-menu-conten {
  320. margin-top: 20rpx;
  321. width: 100%;
  322. height: auto;
  323. box-sizing: border-box;
  324. padding: 0 24rpx;
  325. background-color: #ffffff;
  326. .place-menu-cell {
  327. width: 100%;
  328. height: 110rpx;
  329. box-sizing: border-box;
  330. padding: 36rpx 0;
  331. text-align: left;
  332. float: left;
  333. border-bottom: 1px solid #e1e1e1;
  334. position: relative;
  335. &.last {
  336. border-bottom: none;
  337. }
  338. .place-left {
  339. width: 650rpx;
  340. height: 100%;
  341. .place-menu-icon {
  342. width: 36rpx;
  343. height: 36rpx;
  344. display: block;
  345. float: left;
  346. }
  347. .place-menu-title {
  348. width: 300rpx;
  349. margin-left: 16rpx;
  350. float: left;
  351. height: 36rpx;
  352. line-height: 36rpx;
  353. font-size: $font-size-28;
  354. color: #333333;
  355. }
  356. .coupons-count{
  357. width: 240rpx;
  358. float: right;
  359. height: 36rpx;
  360. line-height: 36rpx;
  361. font-size: $font-size-28;
  362. text-align: right;
  363. color: #FF457B;
  364. }
  365. }
  366. .iconfont {
  367. width: 36rpx;
  368. height: 36rpx;
  369. display: block;
  370. line-height: 36rpx;
  371. text-align: center;
  372. font-size: $font-size-30;
  373. color: #cccccc;
  374. position: absolute;
  375. right: 0;
  376. top: 36rpx;
  377. }
  378. }
  379. }
  380. .user-support {
  381. width: 100%;
  382. float: left;
  383. margin-top: 270rpx;
  384. display: flex;
  385. flex-direction: column;
  386. align-items: center;
  387. justify-content: center;
  388. &.top {
  389. margin-top: 240rpx;
  390. }
  391. .user-support-image {
  392. width: 54rpx;
  393. height: 46rpx;
  394. display: block;
  395. margin-bottom: 5rpx;
  396. }
  397. .user-support-text {
  398. font-size: 20rpx;
  399. line-height: 30rpx;
  400. color: #cccccc;
  401. }
  402. }
  403. </style>