index.vue 8.6 KB

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