index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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.organizeName = response.data.organizeName
  130. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  131. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  132. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  133. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  134. this.isRequest = true
  135. }).catch(error =>{
  136. uni.setStorage({//缓存游客用户openid
  137. key: 'openid',
  138. data: error.data.openid
  139. })
  140. this.logout()
  141. })
  142. },
  143. // 客服
  144. handleContact(e) {
  145. console.log(e.detail.path)
  146. console.log(e.detail.query)
  147. },
  148. navigator(url) {
  149. authorize.getSetting().then(wxResponse => {
  150. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  151. if (wxResponse == 1) {
  152. if (this.hasLogin) {
  153. this.$api.navigateTo(url)
  154. } else {
  155. this.$api.navigateTo('/pages/login/login')
  156. }
  157. } else {
  158. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  159. }
  160. })
  161. },
  162. navigatorNex(url, type) {
  163. authorize.getSetting().then(wxResponse => {
  164. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  165. if (wxResponse == 1) {
  166. if (!this.hasLogin) {
  167. this.$api.navigateTo(url)
  168. }
  169. } else {
  170. this.$api.navigateTo(`/pages/authorization/authorization?type=${type}`)
  171. }
  172. })
  173. },
  174. showBadge(n) {
  175. let num = ''
  176. if (n > 100) {
  177. num = 99
  178. } else {
  179. num = n
  180. }
  181. return num
  182. }
  183. },
  184. onPullDownRefresh() {
  185. //下拉刷新
  186. if (this.hasLogin) {
  187. this.getWxAuthorize()
  188. uni.stopPullDownRefresh()
  189. } else {
  190. uni.stopPullDownRefresh()
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. @import '@/uni.scss';
  197. .container {
  198. background: #f7f7f7;
  199. }
  200. // 用户登录信息区域
  201. .ws-header {
  202. position: relative;
  203. height: 280rpx;
  204. .user-info {
  205. position: absolute;
  206. z-index: 10;
  207. width: 750rpx;
  208. height: 280rpx;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. justify-content: center;
  213. image {
  214. display: block;
  215. width: 120rpx;
  216. height: 120rpx;
  217. border-radius: 50%;
  218. }
  219. }
  220. // 登录按钮
  221. .ws-login {
  222. width: 184rpx;
  223. height: 56rpx;
  224. margin-top: 25rpx;
  225. border-radius: 28rpx;
  226. background: linear-gradient(to right, #fccd90, #b6762f);
  227. line-height: 56rpx;
  228. text-align: center;
  229. color: #ffffff;
  230. font-size: 28rpx;
  231. }
  232. // 公司名
  233. .user-text {
  234. width: 446rpx;
  235. margin-top: 25rpx;
  236. color: #fff;
  237. font-size: 28rpx;
  238. line-height: 40rpx;
  239. text-align: center;
  240. white-space: nowrap;
  241. overflow: hidden;
  242. text-overflow: ellipsis;
  243. }
  244. .user-bg {
  245. width: 100%;
  246. }
  247. }
  248. .more {
  249. width: 750rpx;
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. padding: 23rpx 25rpx;
  254. box-sizing: border-box;
  255. background: #fff;
  256. .more-right {
  257. font-size: 26rpx;
  258. line-height: 37rpx;
  259. margin-right: 10rpx;
  260. }
  261. .title {
  262. font-size: 32rpx;
  263. line-height: 45rpx;
  264. color: #333333;
  265. }
  266. .iconfont {
  267. font-size: 20rpx;
  268. vertical-align: middle;
  269. }
  270. }
  271. .order-wrap {
  272. background: #fff;
  273. .line {
  274. width: 702rpx;
  275. height: 1px;
  276. margin: 0 auto;
  277. background: #f0f0f0;
  278. }
  279. .order-nav {
  280. display: flex;
  281. justify-content: space-evenly;
  282. align-items: center;
  283. padding: 40rpx 0;
  284. .order-nav-item {
  285. display: flex;
  286. align-items: center;
  287. flex-direction: column;
  288. image {
  289. width: 56rpx;
  290. height: 56rpx;
  291. }
  292. text {
  293. font-size: 26rpx;
  294. line-height: 37rpx;
  295. margin-top: 8rpx;
  296. }
  297. }
  298. }
  299. }
  300. .place-order {
  301. width: 750rpx;
  302. display: flex;
  303. justify-content: space-between;
  304. align-items: center;
  305. padding: 23rpx 25rpx;
  306. box-sizing: border-box;
  307. background: #fff;
  308. margin-top: 20rpx;
  309. .place-left {
  310. .title {
  311. font-size: 28rpx;
  312. line-height: 40rpx;
  313. margin-left: 10rpx;
  314. }
  315. .iconfont {
  316. font-size: 36rpx;
  317. vertical-align: middle;
  318. }
  319. }
  320. .iconfont {
  321. font-size: 20rpx;
  322. }
  323. }
  324. .ws-service {
  325. width: 160rpx;
  326. height: 48rpx;
  327. margin: 40rpx auto 0;
  328. display: flex;
  329. justify-content: center;
  330. align-items: center;
  331. font-size: 22rpx;
  332. background: linear-gradient(to right, #fccd90, #b6762f);
  333. color: #fff;
  334. border-radius: 24rpx;
  335. .iconfont {
  336. font-size: 30rpx;
  337. margin-right: 6rpx;
  338. }
  339. }
  340. </style>