index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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 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"
  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 class="place-order" @click="navigator('/pages/user/club/club-list')">
  67. <view class="place-left">
  68. <text class="iconfont icon-bangjigouxiadan"></text>
  69. <text class="title">帮机构下单</text>
  70. </view>
  71. <text class="iconfont icon-chakangengduo"></text>
  72. </view>
  73. <!-- 帮机构下单END -->
  74. <!-- 客服 -->
  75. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  76. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  77. </button>
  78. </template>
  79. </view>
  80. </template>
  81. <script>
  82. import { mapState, mapMutations } from 'vuex'
  83. import authorize from '@/common/config/authorize.js'
  84. import wxLogin from '@/common/config/wxLogin.js'
  85. export default {
  86. data() {
  87. return {
  88. nvabarData: {
  89. //顶部自定义导航
  90. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  91. showSearch: 0,
  92. title: '我的', // 导航栏 中间的标题
  93. haveBack: false,
  94. textLeft: this.$store.state.isIphone,
  95. textColor: '#FFFFFF',
  96. bgColor: ''
  97. },
  98. CustomBar: this.CustomBar, // 顶部导航栏高度
  99. StatusBar: this.StatusBar,
  100. organizeName:'',
  101. isRequest:false,
  102. paymentCount: 0, //待付款角标
  103. waitShipmentsCount: 0, //待收货角标
  104. shipmentsCount: 0, //已发货角标
  105. salesReturnCount: '' //退货/款角标
  106. }
  107. },
  108. onLoad() {
  109. authorize.getSetting().then(res => {
  110. //0:为取消授权 1:为已授权 2:为未操作
  111. if (res == 1) {
  112. this.getWxAuthorize()
  113. }
  114. })
  115. },
  116. computed: {
  117. ...mapState(['hasLogin', 'userInfo'])
  118. },
  119. methods: {
  120. ...mapMutations(['login', 'logout']),
  121. // 获取用户信息
  122. async getWxAuthorize() {
  123. // const wechatCode = await
  124. const wechatCode = await authorize.getCode('weixin')
  125. // 初始化用户状态
  126. this.UserService.userInfoLogin({code:wechatCode}).then(response=>{
  127. this.login(response.data);
  128. this.$store.commit('updateStatus',response.data)
  129. this.getUserInfoPersonal(response.data.organizeId)
  130. }).catch(error =>{
  131. uni.setStorage({//缓存游客用户openid
  132. key: 'openid',
  133. data: error.data.openid
  134. })
  135. this.logout()
  136. })
  137. },
  138. getUserInfoPersonal(organizeId){//初始化个人中心数据
  139. this.UserService.userInfoPersonal({organizeId:organizeId}).then(response=>{
  140. this.organizeName = response.data.organizeName
  141. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  142. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  143. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  144. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  145. this.isRequest = true
  146. }).catch(error =>{
  147. this.$util.msg(error.msg, 2000)
  148. })
  149. },
  150. // 客服
  151. handleContact(e) {
  152. console.log(e.detail.path)
  153. console.log(e.detail.query)
  154. },
  155. navigator(url) {
  156. authorize.getSetting().then(wxResponse => {
  157. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  158. if (wxResponse == 1) {
  159. if (this.hasLogin) {
  160. this.$api.navigateTo(url)
  161. } else {
  162. this.$api.navigateTo('/pages/login/login')
  163. }
  164. } else {
  165. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  166. }
  167. })
  168. },
  169. navigatorNex(url, type) {
  170. authorize.getSetting().then(wxResponse => {
  171. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  172. if (wxResponse == 1) {
  173. if (!this.hasLogin) {
  174. this.$api.navigateTo(url)
  175. }
  176. } else {
  177. this.$api.navigateTo(`/pages/authorization/authorization?type=${type}`)
  178. }
  179. })
  180. },
  181. showBadge(n) {
  182. let num = ''
  183. if (n > 100) {
  184. num = 99
  185. } else {
  186. num = n
  187. }
  188. return num
  189. }
  190. },
  191. onPullDownRefresh() {
  192. //下拉刷新
  193. if (this.hasLogin) {
  194. this.getWxAuthorize()
  195. uni.stopPullDownRefresh()
  196. } else {
  197. uni.stopPullDownRefresh()
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss">
  203. @import '@/uni.scss';
  204. .container {
  205. background: #f7f7f7;
  206. }
  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. image {
  221. display: block;
  222. width: 120rpx;
  223. height: 120rpx;
  224. border-radius: 50%;
  225. }
  226. }
  227. // 登录按钮
  228. .ws-login {
  229. width: 184rpx;
  230. height: 56rpx;
  231. margin-top: 25rpx;
  232. border-radius: 28rpx;
  233. background: linear-gradient(to right, #fccd90, #b6762f);
  234. line-height: 56rpx;
  235. text-align: center;
  236. color: #ffffff;
  237. font-size: 28rpx;
  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. display: flex;
  293. align-items: center;
  294. flex-direction: column;
  295. image {
  296. width: 56rpx;
  297. height: 56rpx;
  298. }
  299. text {
  300. font-size: 26rpx;
  301. line-height: 37rpx;
  302. margin-top: 8rpx;
  303. }
  304. }
  305. }
  306. }
  307. .place-order {
  308. width: 750rpx;
  309. display: flex;
  310. justify-content: space-between;
  311. align-items: center;
  312. padding: 23rpx 25rpx;
  313. box-sizing: border-box;
  314. background: #fff;
  315. margin-top: 20rpx;
  316. .place-left {
  317. .title {
  318. font-size: 28rpx;
  319. line-height: 40rpx;
  320. margin-left: 10rpx;
  321. }
  322. .iconfont {
  323. font-size: 36rpx;
  324. vertical-align: middle;
  325. }
  326. }
  327. .iconfont {
  328. font-size: 20rpx;
  329. }
  330. }
  331. .ws-service {
  332. width: 160rpx;
  333. height: 48rpx;
  334. margin: 40rpx auto 0;
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. font-size: 22rpx;
  339. background: linear-gradient(to right, #fccd90, #b6762f);
  340. color: #fff;
  341. border-radius: 24rpx;
  342. .iconfont {
  343. font-size: 30rpx;
  344. margin-right: 6rpx;
  345. }
  346. }
  347. </style>