index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <template v-show="!isRequest">
  5. <view class="ws-header">
  6. <!-- 用户信息 -->
  7. <view class="user-info">
  8. <image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
  9. <view
  10. class="ws-login"
  11. @click="navigator('/pages/login/login')"
  12. v-if="!hasLogin && !isRequest"
  13. >
  14. 请登录
  15. </view>
  16. <view class="user-text" v-else> {{ organizeName }} </view>
  17. </view>
  18. <!-- 背景图 -->
  19. <image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
  20. </view>
  21. <!-- 机构信息END -->
  22. <!-- 订单状态区域 -->
  23. <view class="order-wrap">
  24. <view class="more">
  25. <text class="title">我的订单</text>
  26. <view @click="navigator('/pages/user/order/order-list?state=0')">
  27. <text class="more-right">全部订单</text>
  28. <text class="iconfont icon-chakangengduo"></text>
  29. </view>
  30. </view>
  31. <view class="line"></view>
  32. <!-- 菜单选项 -->
  33. <view class="order-nav">
  34. <view
  35. class="order-nav-item"
  36. @click="navigator('/pages/user/order/order-list?state=1')"
  37. >
  38. <image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
  39. <text>待付款</text>
  40. </view>
  41. <view
  42. class="order-nav-item"
  43. @click="navigator('/pages/user/order/order-list?state=2')"
  44. >
  45. <image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
  46. <text>待发货</text>
  47. </view>
  48. <view
  49. class="order-nav-item"
  50. @click="navigator('/pages/user/order/order-list?state=3')"
  51. >
  52. <image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
  53. <text>已发货</text>
  54. </view>
  55. <view
  56. class="order-nav-item"
  57. @click="navigator('/pages/user/order/order-list?state=4')"
  58. >
  59. <image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
  60. <text>退货/款</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 订单状态区域END -->
  65. <!-- 帮机构下单 -->
  66. <view
  67. class="place-order"
  68. @click="navigator(`/pages/user/club/club-list?id=${organizeId}`)"
  69. >
  70. <view class="place-left">
  71. <text class="iconfont icon-bangjigouxiadan"></text>
  72. <text class="title">帮机构下单</text>
  73. </view>
  74. <text class="iconfont icon-chakangengduo"></text>
  75. </view>
  76. <!-- 帮机构下单END -->
  77. <!-- 客服 -->
  78. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  79. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  80. </button>
  81. </template>
  82. </view>
  83. </template>
  84. <script>
  85. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  86. import { mapState, mapMutations } from 'vuex'
  87. import authorize from '@/common/config/authorize.js'
  88. import wxLogin from '@/common/config/wxLogin.js'
  89. export default {
  90. components: {
  91. nutBadge
  92. },
  93. data() {
  94. return {
  95. organizeName: '', //采购员组织名称
  96. isRequest: false,
  97. paymentCount: 0, //待付款角标
  98. waitShipmentsCount: 0, //待收货角标
  99. shipmentsCount: 0, //已发货角标
  100. salesReturnCount: '', //退货/款角标
  101. organizeId: '',
  102. refresh:false
  103. }
  104. },
  105. onLoad() {
  106. // 获取用户是否授权
  107. //0:为取消授权 1:为已授权 2:为未操作
  108. authorize.getSetting().then(res => {
  109. if (res == 1) {
  110. console.log('用户已授权')
  111. this.GetWxAuthorize()
  112. }
  113. })
  114. },
  115. computed: {
  116. ...mapState(['hasLogin', 'userInfo'])
  117. },
  118. methods: {
  119. ...mapMutations(['login', 'logout']),
  120. // 授权登录验证
  121. async GetWxAuthorize() {
  122. // 获取微信code
  123. const wechatCode = await authorize.getCode('weixin')
  124. this.UserService.userInfoLogin({code:wechatCode}).then(res=>{
  125. // 登录成功 将信息保存在userInfo中 保存在本地和store
  126. this.login(res.data)
  127. this.organizeId = res.data.organizeId
  128. this.getUserInfoPersonal(this.organizeId)
  129. this.refresh = true
  130. }).catch(err=>{
  131. // 缓存游客openid
  132. uni.setStorageSync('openid',err.data.openid)
  133. this.logout()
  134. this.refresh = true
  135. })
  136. },
  137. //初始化个人中心数据
  138. getUserInfoPersonal(organizeId) {
  139. this.UserService.userInfoPersonal({ organizeId: organizeId })
  140. .then(response => {
  141. this.organizeName = response.data.organizeName //采购员组织名称
  142. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  143. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  144. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  145. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  146. this.isRequest = true //个人中心初始化成功后才显示页面
  147. })
  148. .catch(error => {
  149. this.$util.msg(error.msg, 2000)
  150. })
  151. },
  152. // 客服
  153. handleContact(e) {
  154. console.log(e.detail.path)
  155. console.log(e.detail.query)
  156. },
  157. // 栏目跳转
  158. navigator(url) {
  159. authorize.getSetting().then(res => {
  160. // console.log('是否已授权',res);
  161. //0:为取消授权 1:为已授权 2:为未操作
  162. if (res == 1) {
  163. if (this.hasLogin) {
  164. // 已登录
  165. this.$api.navigateTo(url)
  166. } else {
  167. // 未登录
  168. this.$api.navigateTo(`/pages/login/login`)
  169. }
  170. } else {
  171. this.$api.navigateTo(`/pages/authorization/authorization`)
  172. }
  173. })
  174. },
  175. //下拉刷新
  176. onPullDownRefresh() {
  177. if (this.hasLogin) {
  178. this.GetWxAuthorize()
  179. if(this.refresh){
  180. uni.stopPullDownRefresh()
  181. }
  182. } else {
  183. uni.stopPullDownRefresh()
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss">
  190. @import '@/uni.scss';
  191. .container {
  192. background: #f7f7f7;
  193. }
  194. // 用户登录信息区域
  195. .ws-header {
  196. position: relative;
  197. height: 280rpx;
  198. .user-info {
  199. position: absolute;
  200. z-index: 10;
  201. width: 750rpx;
  202. height: 280rpx;
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. justify-content: center;
  207. image {
  208. display: block;
  209. width: 120rpx;
  210. height: 120rpx;
  211. border-radius: 50%;
  212. }
  213. }
  214. // 登录按钮
  215. .ws-login {
  216. width: 184rpx;
  217. height: 56rpx;
  218. margin-top: 25rpx;
  219. border-radius: 28rpx;
  220. background: linear-gradient(to right, #fccd90, #b6762f);
  221. line-height: 56rpx;
  222. text-align: center;
  223. color: #ffffff;
  224. font-size: 28rpx;
  225. }
  226. // 公司名
  227. .user-text {
  228. width: 446rpx;
  229. margin-top: 25rpx;
  230. color: #fff;
  231. font-size: 28rpx;
  232. line-height: 40rpx;
  233. text-align: center;
  234. white-space: nowrap;
  235. overflow: hidden;
  236. text-overflow: ellipsis;
  237. }
  238. .user-bg {
  239. width: 100%;
  240. }
  241. }
  242. .more {
  243. width: 750rpx;
  244. display: flex;
  245. justify-content: space-between;
  246. align-items: center;
  247. padding: 23rpx 25rpx;
  248. box-sizing: border-box;
  249. background: #fff;
  250. .more-right {
  251. font-size: 26rpx;
  252. line-height: 37rpx;
  253. margin-right: 10rpx;
  254. }
  255. .title {
  256. font-size: 32rpx;
  257. line-height: 45rpx;
  258. color: #333333;
  259. }
  260. .iconfont {
  261. font-size: 20rpx;
  262. vertical-align: middle;
  263. }
  264. }
  265. .order-wrap {
  266. background: #fff;
  267. .line {
  268. width: 702rpx;
  269. height: 1px;
  270. margin: 0 auto;
  271. background: #f0f0f0;
  272. }
  273. .order-nav {
  274. display: flex;
  275. justify-content: space-evenly;
  276. align-items: center;
  277. padding: 40rpx 0;
  278. .order-nav-item {
  279. display: flex;
  280. align-items: center;
  281. flex-direction: column;
  282. image {
  283. width: 56rpx;
  284. height: 56rpx;
  285. }
  286. text {
  287. font-size: 26rpx;
  288. line-height: 37rpx;
  289. margin-top: 8rpx;
  290. }
  291. }
  292. }
  293. }
  294. .place-order {
  295. width: 750rpx;
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. padding: 23rpx 25rpx;
  300. box-sizing: border-box;
  301. background: #fff;
  302. margin-top: 20rpx;
  303. .place-left {
  304. .title {
  305. font-size: 28rpx;
  306. line-height: 40rpx;
  307. margin-left: 10rpx;
  308. }
  309. .iconfont {
  310. font-size: 36rpx;
  311. vertical-align: middle;
  312. }
  313. }
  314. .iconfont {
  315. font-size: 20rpx;
  316. }
  317. }
  318. .ws-service {
  319. width: 160rpx;
  320. height: 48rpx;
  321. margin: 40rpx auto 0;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. font-size: 22rpx;
  326. background: linear-gradient(to right, #fccd90, #b6762f);
  327. color: #fff;
  328. border-radius: 24rpx;
  329. .iconfont {
  330. font-size: 30rpx;
  331. margin-right: 6rpx;
  332. }
  333. }
  334. .badge {
  335. background-color: #ff0000;
  336. }
  337. </style>