index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="container" :style="{paddingTop :CustomBar + 'px' }">
  3. <cm-custom :navbar-data='nvabarData'></cm-custom>
  4. <!-- 机构信息区域 -->
  5. <template v-show="!isRequest">
  6. <!-- <view class="ws-title" :style="{lineHeight :CustomBar + 'px' }">维沙采购商城</view> -->
  7. <view class="ws-header">
  8. <!-- 用户信息 -->
  9. <view class="user-info">
  10. <image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
  11. <view
  12. class="ws-login"
  13. @click="navigator('/pages/login/login')"
  14. v-if="!hasLogin && !isRequest"
  15. >
  16. 请登录
  17. </view>
  18. <view class="user-text" v-else> {{ organizeName }} </view>
  19. </view>
  20. <!-- 背景图 -->
  21. <image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
  22. </view>
  23. <!-- 机构信息END -->
  24. <!-- 订单状态区域 -->
  25. <view class="order-wrap">
  26. <view class="more">
  27. <text class="title">我的订单</text>
  28. <view @click="navigator('/pages/user/order/order-list?state=0')">
  29. <text class="more-right">全部订单</text>
  30. <text class="iconfont icon-chakangengduo"></text>
  31. </view>
  32. </view>
  33. <view class="line"></view>
  34. <!-- 菜单选项 -->
  35. <view class="order-nav">
  36. <view
  37. class="order-nav-item"
  38. @click="navigator('/pages/user/order/order-list?state=1')"
  39. >
  40. <image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
  41. <text>待付款</text>
  42. </view>
  43. <view
  44. class="order-nav-item"
  45. @click="navigator('/pages/user/order/order-list?state=2')"
  46. >
  47. <image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
  48. <text>待发货</text>
  49. </view>
  50. <view
  51. class="order-nav-item"
  52. @click="navigator('/pages/user/order/order-list?state=3')"
  53. >
  54. <image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
  55. <text>已发货</text>
  56. </view>
  57. <view
  58. class="order-nav-item"
  59. @click="navigator('/pages/user/order/order-list?state=4')"
  60. >
  61. <image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
  62. <text>退货/款</text>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 订单状态区域END -->
  67. <!-- 帮机构下单 -->
  68. <view
  69. class="place-order"
  70. @click="navigator(`/pages/user/club/club-list?id=${organizeId}`)"
  71. >
  72. <view class="place-left">
  73. <text class="iconfont icon-bangjigouxiadan"></text>
  74. <text class="title">帮机构下单</text>
  75. </view>
  76. <text class="iconfont icon-chakangengduo"></text>
  77. </view>
  78. <!-- 帮机构下单END -->
  79. <!-- 客服 -->
  80. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  81. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  82. </button>
  83. </template>
  84. </view>
  85. </template>
  86. <script>
  87. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  88. import { mapState, mapMutations } from 'vuex'
  89. import authorize from '@/common/config/authorize.js'
  90. import wxLogin from '@/common/config/wxLogin.js'
  91. export default {
  92. components: {
  93. nutBadge
  94. },
  95. data() {
  96. return {
  97. nvabarData: {//顶部自定义导航
  98. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  99. showSearch: 0,
  100. title: '维沙采购商城', // 导航栏 中间的标题
  101. haveBack:false,
  102. textLeft:this.$store.state.isIphone,
  103. textColor:'#333333',
  104. bgColor:'#ffffff'
  105. },
  106. CustomBar:this.CustomBar,// 顶部导航栏高度
  107. organizeName: '', //采购员组织名称
  108. isRequest: false,
  109. paymentCount: 0, //待付款角标
  110. waitShipmentsCount: 0, //待收货角标
  111. shipmentsCount: 0, //已发货角标
  112. salesReturnCount: '', //退货/款角标
  113. organizeId: '',
  114. refresh:false
  115. }
  116. },
  117. onLoad() {
  118. // 获取用户是否授权
  119. //0:为取消授权 1:为已授权 2:为未操作
  120. authorize.getSetting().then(res => {
  121. if (res == 1) {
  122. console.log('用户已授权')
  123. this.GetWxAuthorize()
  124. }
  125. })
  126. },
  127. computed: {
  128. ...mapState(['hasLogin', 'userInfo'])
  129. },
  130. methods: {
  131. ...mapMutations(['login', 'logout']),
  132. // 授权登录验证
  133. async GetWxAuthorize() {
  134. // 获取微信code
  135. const wechatCode = await authorize.getCode('weixin')
  136. this.UserService.userInfoLogin({code:wechatCode}).then(res=>{
  137. // 登录成功 将信息保存在userInfo中 保存在本地和store
  138. this.login(res.data)
  139. this.organizeId = res.data.organizeId
  140. this.getUserInfoPersonal(this.organizeId)
  141. this.refresh = true
  142. }).catch(err=>{
  143. // 缓存游客openid
  144. uni.setStorageSync('openid',err.data.openid)
  145. this.logout()
  146. this.refresh = true
  147. })
  148. },
  149. //初始化个人中心数据
  150. getUserInfoPersonal(organizeId) {
  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. // 栏目跳转
  170. navigator(url) {
  171. authorize.getSetting().then(res => {
  172. // console.log('是否已授权',res);
  173. //0:为取消授权 1:为已授权 2:为未操作
  174. if (res == 1) {
  175. if (this.hasLogin) {
  176. // 已登录
  177. this.$api.navigateTo(url)
  178. } else {
  179. // 未登录
  180. this.$api.navigateTo(`/pages/login/login`)
  181. }
  182. } else {
  183. this.$api.navigateTo(`/pages/authorization/authorization`)
  184. }
  185. })
  186. },
  187. //下拉刷新
  188. onPullDownRefresh() {
  189. if (this.hasLogin) {
  190. this.GetWxAuthorize()
  191. if(this.refresh){
  192. uni.stopPullDownRefresh()
  193. }
  194. } else {
  195. uni.stopPullDownRefresh()
  196. }
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. @import '@/uni.scss';
  203. .container {
  204. background: #f7f7f7;
  205. }
  206. // 用户登录信息区域
  207. .ws-title{
  208. width: 100%;
  209. position: fixed;
  210. top:0 ;
  211. left: 0;
  212. font-size: 34rpx;
  213. text-align: center;
  214. }
  215. .ws-header {
  216. position: relative;
  217. height: 280rpx;
  218. .user-info {
  219. position: absolute;
  220. z-index: 10;
  221. width: 750rpx;
  222. height: 280rpx;
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. image {
  228. display: block;
  229. width: 120rpx;
  230. height: 120rpx;
  231. border-radius: 50%;
  232. }
  233. }
  234. // 登录按钮
  235. .ws-login {
  236. width: 184rpx;
  237. height: 56rpx;
  238. margin-top: 25rpx;
  239. border-radius: 28rpx;
  240. background: linear-gradient(to right, #fccd90, #b6762f);
  241. line-height: 56rpx;
  242. text-align: center;
  243. color: #ffffff;
  244. font-size: 28rpx;
  245. }
  246. // 公司名
  247. .user-text {
  248. width: 446rpx;
  249. margin-top: 25rpx;
  250. color: #fff;
  251. font-size: 28rpx;
  252. line-height: 40rpx;
  253. text-align: center;
  254. white-space: nowrap;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. }
  258. .user-bg {
  259. width: 100%;
  260. }
  261. }
  262. .more {
  263. width: 750rpx;
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. padding: 23rpx 25rpx;
  268. box-sizing: border-box;
  269. background: #fff;
  270. .more-right {
  271. font-size: 26rpx;
  272. line-height: 37rpx;
  273. margin-right: 10rpx;
  274. }
  275. .title {
  276. font-size: 32rpx;
  277. line-height: 45rpx;
  278. color: #333333;
  279. }
  280. .iconfont {
  281. font-size: 20rpx;
  282. vertical-align: middle;
  283. }
  284. }
  285. .order-wrap {
  286. background: #fff;
  287. .line {
  288. width: 702rpx;
  289. height: 1px;
  290. margin: 0 auto;
  291. background: #f0f0f0;
  292. }
  293. .order-nav {
  294. display: flex;
  295. justify-content: space-evenly;
  296. align-items: center;
  297. padding: 40rpx 0;
  298. .order-nav-item {
  299. display: flex;
  300. align-items: center;
  301. flex-direction: column;
  302. image {
  303. width: 56rpx;
  304. height: 56rpx;
  305. }
  306. text {
  307. font-size: 26rpx;
  308. line-height: 37rpx;
  309. margin-top: 8rpx;
  310. }
  311. }
  312. }
  313. }
  314. .place-order {
  315. width: 750rpx;
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. padding: 23rpx 25rpx;
  320. box-sizing: border-box;
  321. background: #fff;
  322. margin-top: 20rpx;
  323. .place-left {
  324. .title {
  325. font-size: 28rpx;
  326. line-height: 40rpx;
  327. margin-left: 10rpx;
  328. }
  329. .iconfont {
  330. font-size: 36rpx;
  331. vertical-align: middle;
  332. }
  333. }
  334. .iconfont {
  335. font-size: 20rpx;
  336. }
  337. }
  338. .ws-service {
  339. width: 160rpx;
  340. height: 48rpx;
  341. margin: 40rpx auto 0;
  342. display: flex;
  343. justify-content: center;
  344. align-items: center;
  345. font-size: 22rpx;
  346. background: linear-gradient(to right, #fccd90, #b6762f);
  347. color: #fff;
  348. border-radius: 24rpx;
  349. .iconfont {
  350. font-size: 30rpx;
  351. margin-right: 6rpx;
  352. }
  353. }
  354. .badge {
  355. background-color: #ff0000;
  356. }
  357. </style>