index.vue 8.0 KB

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