index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <template>
  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. nvabarData: {
  96. //顶部自定义导航
  97. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  98. showSearch: 0,
  99. title: '我的', // 导航栏 中间的标题
  100. haveBack: false,
  101. textLeft: this.$store.state.isIphone,
  102. textColor: '#FFFFFF',
  103. bgColor: ''
  104. },
  105. CustomBar: this.CustomBar, // 顶部导航栏高度
  106. StatusBar: this.StatusBar,
  107. organizeName: '',
  108. isRequest: false,
  109. paymentCount: 0, //待付款角标
  110. waitShipmentsCount: 0, //待收货角标
  111. shipmentsCount: 0, //已发货角标
  112. salesReturnCount: '', //退货/款角标
  113. organizeId: ''
  114. }
  115. },
  116. onLoad() {
  117. authorize.getSetting().then(res => {
  118. //0:为取消授权 1:为已授权 2:为未操作
  119. if (res == 1) {
  120. this.GetWxAuthorize()
  121. }
  122. })
  123. },
  124. computed: {
  125. ...mapState(['hasLogin', 'userInfo'])
  126. },
  127. methods: {
  128. ...mapMutations(['login', 'logout']),
  129. async GetWxAuthorize() {
  130. const wechatCode = await authorize.getCode('weixin')
  131. this.UserService.userInfoLogin({ code: wechatCode })
  132. .then(response => {
  133. // 保存登录信息
  134. this.login(response.data)
  135. console.log(response)
  136. this.$store.commit('updateStatus', response.data)
  137. this.organizeId = response.data.organizeId
  138. this.getUserInfoPersonal(response.data.organizeId)
  139. })
  140. .catch(error => {
  141. uni.setStorage({
  142. //缓存游客用户openid
  143. key: 'openid',
  144. data: error.data.openid
  145. })
  146. this.logout()
  147. })
  148. this.UserService.userInfoLogin({ code: wechatCode })
  149. .then(response => {
  150. this.login(response.data)
  151. this.$store.commit('updateStatus', response.data)
  152. this.GetUserInfoPersonal(response.data.organizeId)
  153. })
  154. .catch(error => {
  155. uni.setStorage({
  156. //缓存游客用户openid
  157. key: 'openid',
  158. data: error.data.openid
  159. })
  160. })
  161. },
  162. getUserInfoPersonal(organizeId) {
  163. //初始化个人中心数据
  164. this.UserService.userInfoPersonal({ organizeId: organizeId })
  165. .then(response => {
  166. this.organizeName = response.data.organizeName
  167. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  168. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  169. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  170. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  171. this.isRequest = true //个人中心初始化成功后才显示页面
  172. })
  173. .catch(error => {
  174. this.$util.msg(error.msg, 2000)
  175. })
  176. },
  177. handleContact(e) {
  178. console.log(e.detail.path)
  179. console.log(e.detail.query)
  180. },
  181. navigator(url) {
  182. authorize.getSetting().then(wxResponse => {
  183. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  184. if (wxResponse == 1) {
  185. if (this.hasLogin) {
  186. // 已登录
  187. this.$api.navigateTo(url)
  188. } else {
  189. // 未登录
  190. this.$api.navigateTo(`/pages/login/login`)
  191. }
  192. } else {
  193. this.$api.navigateTo(`/pages/authorization/authorization`)
  194. }
  195. })
  196. },
  197. navigatorNex(url, type) {
  198. authorize.getSetting().then(wxResponse => {
  199. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  200. if (wxResponse == 1) {
  201. if (!this.hasLogin) {
  202. this.$api.navigateTo(url)
  203. }
  204. } else {
  205. this.$api.navigateTo(`/pages/authorization/authorization?type=${type}`)
  206. }
  207. })
  208. },
  209. showBadge(n) {
  210. let num = ''
  211. if (n > 100) {
  212. num = 99
  213. } else {
  214. num = n
  215. }
  216. return num
  217. },
  218. onPullDownRefresh() {
  219. //下拉刷新
  220. if (this.hasLogin) {
  221. this.GetWxAuthorize()
  222. uni.stopPullDownRefresh()
  223. } else {
  224. uni.stopPullDownRefresh()
  225. }
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. @import '@/uni.scss';
  232. .container {
  233. background: #f7f7f7;
  234. }
  235. // 用户登录信息区域
  236. .ws-header {
  237. position: relative;
  238. height: 280rpx;
  239. .user-info {
  240. position: absolute;
  241. z-index: 10;
  242. width: 750rpx;
  243. height: 280rpx;
  244. display: flex;
  245. flex-direction: column;
  246. align-items: center;
  247. justify-content: center;
  248. image {
  249. display: block;
  250. width: 120rpx;
  251. height: 120rpx;
  252. border-radius: 50%;
  253. }
  254. }
  255. // 登录按钮
  256. .ws-login {
  257. width: 184rpx;
  258. height: 56rpx;
  259. margin-top: 25rpx;
  260. border-radius: 28rpx;
  261. background: linear-gradient(to right, #fccd90, #b6762f);
  262. line-height: 56rpx;
  263. text-align: center;
  264. color: #ffffff;
  265. font-size: 28rpx;
  266. }
  267. // 公司名
  268. .user-text {
  269. width: 446rpx;
  270. margin-top: 25rpx;
  271. color: #fff;
  272. font-size: 28rpx;
  273. line-height: 40rpx;
  274. text-align: center;
  275. white-space: nowrap;
  276. overflow: hidden;
  277. text-overflow: ellipsis;
  278. }
  279. .user-bg {
  280. width: 100%;
  281. }
  282. }
  283. .more {
  284. width: 750rpx;
  285. display: flex;
  286. justify-content: space-between;
  287. align-items: center;
  288. padding: 23rpx 25rpx;
  289. box-sizing: border-box;
  290. background: #fff;
  291. .more-right {
  292. font-size: 26rpx;
  293. line-height: 37rpx;
  294. margin-right: 10rpx;
  295. }
  296. .title {
  297. font-size: 32rpx;
  298. line-height: 45rpx;
  299. color: #333333;
  300. }
  301. .iconfont {
  302. font-size: 20rpx;
  303. vertical-align: middle;
  304. }
  305. }
  306. .order-wrap {
  307. background: #fff;
  308. .line {
  309. width: 702rpx;
  310. height: 1px;
  311. margin: 0 auto;
  312. background: #f0f0f0;
  313. }
  314. .order-nav {
  315. display: flex;
  316. justify-content: space-evenly;
  317. align-items: center;
  318. padding: 40rpx 0;
  319. .order-nav-item {
  320. display: flex;
  321. align-items: center;
  322. flex-direction: column;
  323. image {
  324. width: 56rpx;
  325. height: 56rpx;
  326. }
  327. text {
  328. font-size: 26rpx;
  329. line-height: 37rpx;
  330. margin-top: 8rpx;
  331. }
  332. }
  333. }
  334. }
  335. .place-order {
  336. width: 750rpx;
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. padding: 23rpx 25rpx;
  341. box-sizing: border-box;
  342. background: #fff;
  343. margin-top: 20rpx;
  344. .place-left {
  345. .title {
  346. font-size: 28rpx;
  347. line-height: 40rpx;
  348. margin-left: 10rpx;
  349. }
  350. .iconfont {
  351. font-size: 36rpx;
  352. vertical-align: middle;
  353. }
  354. }
  355. .iconfont {
  356. font-size: 20rpx;
  357. }
  358. }
  359. .ws-service {
  360. width: 160rpx;
  361. height: 48rpx;
  362. margin: 40rpx auto 0;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. font-size: 22rpx;
  367. background: linear-gradient(to right, #fccd90, #b6762f);
  368. color: #fff;
  369. border-radius: 24rpx;
  370. .iconfont {
  371. font-size: 30rpx;
  372. margin-right: 6rpx;
  373. }
  374. }
  375. .badge {
  376. background-color: #ff0000;
  377. }
  378. </style>