index.vue 13 KB

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