index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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" v-if="unusedNum > 0">{{ unusedNum }}</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">
  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', 'unusedNum'])
  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. this.initReceiveCouponCount()
  140. }
  141. },
  142. methods: {
  143. ...mapMutations('app', ['login', 'logout']),
  144. ...mapActions('cart', ['getCartNumber']),
  145. ...mapActions('coupon', ['initReceiveCouponCount']),
  146. //初始化个人中心数据
  147. GetUserInfoPersonal() {
  148. this.UserService.GetUserOrderTotal({
  149. userId: this.userId
  150. })
  151. .then(response => {
  152. const data = response.data
  153. this.paymentCount = data.paymentCount //待付款
  154. this.waitShipmentsCount = data.waitShipmentsCount //待收货
  155. this.shipmentsCount = data.shipmentsCount //已发货
  156. this.salesReturnCount = data.salesReturnCount //退货/款
  157. })
  158. .catch(error => {
  159. this.$util.msg(error.msg, 2000)
  160. })
  161. },
  162. handleContact(e) {
  163. //客服
  164. console.log(e.detail.path)
  165. console.log(e.detail.query)
  166. },
  167. OrderNavigator(state) {
  168. if (!this.hasLogin) return this.$api.navigateTo('/pages/login/login')
  169. // 栏目跳转
  170. this.$api.navigateTo(`/pages/order/order-list?state=${state}`)
  171. },
  172. navigator(url) {
  173. if (this.hasLogin) {
  174. this.$api.navigateTo(url)
  175. } else {
  176. this.$api.navigateTo('/pages/login/login')
  177. }
  178. }
  179. },
  180. onPullDownRefresh() {
  181. //下拉刷新
  182. if (this.hasLogin) {
  183. this.GetUserInfo()
  184. setTimeout(() => {
  185. uni.stopPullDownRefresh()
  186. }, 2000)
  187. } else {
  188. uni.stopPullDownRefresh()
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss">
  194. @import '@/uni.scss';
  195. .container {
  196. box-sizing: border-box;
  197. background: #f7f7f7;
  198. }
  199. // 用户登录信息区域
  200. .ws-title {
  201. width: 100%;
  202. position: fixed;
  203. top: 0;
  204. left: 0;
  205. font-size: 34rpx;
  206. text-align: center;
  207. }
  208. .ws-header {
  209. position: relative;
  210. height: 280rpx;
  211. .user-info {
  212. position: absolute;
  213. z-index: 10;
  214. width: 750rpx;
  215. height: 280rpx;
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. justify-content: center;
  220. .user_default {
  221. display: block;
  222. width: 120rpx;
  223. height: 120rpx;
  224. border-radius: 50%;
  225. }
  226. }
  227. // 登录按钮
  228. .user-login {
  229. width: 184rpx;
  230. height: 56rpx;
  231. margin-top: 25rpx;
  232. border-radius: 28rpx;
  233. background: #ffffff;
  234. line-height: 56rpx;
  235. text-align: center;
  236. color: $color-system;
  237. font-size: $font-size-28;
  238. }
  239. // 公司名
  240. .user-text {
  241. width: 446rpx;
  242. margin-top: 25rpx;
  243. color: #fff;
  244. font-size: 28rpx;
  245. line-height: 40rpx;
  246. text-align: center;
  247. white-space: nowrap;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. }
  251. .user-bg {
  252. width: 100%;
  253. }
  254. }
  255. .more {
  256. width: 750rpx;
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. padding: 23rpx 25rpx;
  261. box-sizing: border-box;
  262. background: #fff;
  263. .more-right {
  264. font-size: 26rpx;
  265. line-height: 37rpx;
  266. margin-right: 10rpx;
  267. }
  268. .title {
  269. font-size: 32rpx;
  270. line-height: 45rpx;
  271. color: #333333;
  272. }
  273. .iconfont {
  274. font-size: 20rpx;
  275. vertical-align: middle;
  276. }
  277. }
  278. .order-wrap {
  279. background: #fff;
  280. .line {
  281. width: 702rpx;
  282. height: 1px;
  283. margin: 0 auto;
  284. background: #f0f0f0;
  285. }
  286. .order-nav {
  287. display: flex;
  288. justify-content: space-evenly;
  289. align-items: center;
  290. padding: 40rpx 0;
  291. .order-nav-item {
  292. position: relative;
  293. display: flex;
  294. align-items: center;
  295. flex-direction: column;
  296. image {
  297. width: 64rpx;
  298. height: 64rpx;
  299. }
  300. text {
  301. font-size: 26rpx;
  302. line-height: 37rpx;
  303. margin-top: 8rpx;
  304. }
  305. .tui-badge {
  306. position: absolute;
  307. top: -15rpx;
  308. right: -25rpx;
  309. z-index: 999;
  310. }
  311. }
  312. }
  313. }
  314. .place-menu-conten {
  315. margin-top: 20rpx;
  316. width: 100%;
  317. height: auto;
  318. box-sizing: border-box;
  319. padding: 0 24rpx;
  320. background-color: #ffffff;
  321. .place-menu-cell {
  322. width: 100%;
  323. height: 110rpx;
  324. box-sizing: border-box;
  325. padding: 36rpx 0;
  326. text-align: left;
  327. float: left;
  328. border-bottom: 1px solid #e1e1e1;
  329. position: relative;
  330. &.last {
  331. border-bottom: none;
  332. }
  333. .place-left {
  334. width: 650rpx;
  335. height: 100%;
  336. .place-menu-icon {
  337. width: 36rpx;
  338. height: 36rpx;
  339. display: block;
  340. float: left;
  341. }
  342. .place-menu-title {
  343. width: 300rpx;
  344. margin-left: 16rpx;
  345. float: left;
  346. height: 36rpx;
  347. line-height: 36rpx;
  348. font-size: $font-size-28;
  349. color: #333333;
  350. }
  351. .coupons-count {
  352. width: 240rpx;
  353. float: right;
  354. height: 36rpx;
  355. line-height: 36rpx;
  356. font-size: $font-size-28;
  357. text-align: right;
  358. color: #ff457b;
  359. }
  360. }
  361. .iconfont {
  362. width: 36rpx;
  363. height: 36rpx;
  364. display: block;
  365. line-height: 36rpx;
  366. text-align: center;
  367. font-size: $font-size-30;
  368. color: #cccccc;
  369. position: absolute;
  370. right: 0;
  371. top: 36rpx;
  372. }
  373. }
  374. }
  375. .user-support {
  376. position: fixed;
  377. bottom: 30rpx;
  378. width: 100%;
  379. float: left;
  380. display: flex;
  381. flex-direction: column;
  382. align-items: center;
  383. justify-content: center;
  384. .user-support-image {
  385. width: 54rpx;
  386. height: 46rpx;
  387. display: block;
  388. margin-bottom: 5rpx;
  389. }
  390. .user-support-text {
  391. font-size: 20rpx;
  392. line-height: 30rpx;
  393. color: #cccccc;
  394. }
  395. }
  396. </style>