index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view class="container" :style="{paddingTop :CustomBar + 'px' }">
  3. <cm-custom :navbar-data='nvabarData'></cm-custom>
  4. <!-- 机构信息区域 -->
  5. <template v-if="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. this.isRequest = true;
  143. }).catch(err=>{
  144. // 缓存游客openid
  145. uni.setStorageSync('openid',err.data.openid)
  146. this.logout()
  147. this.refresh = true
  148. this.isRequest = true;
  149. })
  150. },
  151. //初始化个人中心数据
  152. getUserInfoPersonal(organizeId) {
  153. this.UserService.userInfoPersonal({ organizeId: organizeId })
  154. .then(response => {
  155. this.organizeName = response.data.organizeName //采购员组织名称
  156. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  157. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  158. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  159. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  160. })
  161. .catch(error => {
  162. this.$util.msg(error.msg, 2000)
  163. })
  164. },
  165. // 客服
  166. handleContact(e) {
  167. console.log(e.detail.path)
  168. console.log(e.detail.query)
  169. },
  170. // 栏目跳转
  171. navigator(url) {
  172. authorize.getSetting().then(res => {
  173. // console.log('是否已授权',res);
  174. //0:为取消授权 1:为已授权 2:为未操作
  175. if (res == 1) {
  176. if (this.hasLogin) {
  177. // 已登录
  178. this.$api.navigateTo(url)
  179. } else {
  180. // 未登录
  181. this.$api.navigateTo(`/pages/login/login`)
  182. }
  183. } else {
  184. this.$api.navigateTo(`/pages/authorization/authorization`)
  185. }
  186. })
  187. },
  188. //下拉刷新
  189. onPullDownRefresh() {
  190. if (this.hasLogin) {
  191. this.GetWxAuthorize()
  192. if(this.refresh){
  193. uni.stopPullDownRefresh()
  194. }
  195. } else {
  196. uni.stopPullDownRefresh()
  197. }
  198. },
  199. onShareAppMessage (res){//分享转发
  200. this.isShareModal = false
  201. if (res.from === 'button') {// 来自页面内转发按钮
  202. }
  203. return {
  204. title: '维沙采购商城上线啦,快来采购吧~',
  205. path: `/pages/index/index`,
  206. imageUrl:'https://static-b.caimei365.com/app/wisa/img/icon/icon-index.png'
  207. }
  208. },
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. @import '@/uni.scss';
  214. .container {
  215. background: #f7f7f7;
  216. }
  217. // 用户登录信息区域
  218. .ws-title{
  219. width: 100%;
  220. position: fixed;
  221. top:0 ;
  222. left: 0;
  223. font-size: 34rpx;
  224. text-align: center;
  225. }
  226. .ws-header {
  227. position: relative;
  228. height: 280rpx;
  229. .user-info {
  230. position: absolute;
  231. z-index: 10;
  232. width: 750rpx;
  233. height: 280rpx;
  234. display: flex;
  235. flex-direction: column;
  236. align-items: center;
  237. justify-content: center;
  238. image {
  239. display: block;
  240. width: 120rpx;
  241. height: 120rpx;
  242. border-radius: 50%;
  243. }
  244. }
  245. // 登录按钮
  246. .ws-login {
  247. width: 184rpx;
  248. height: 56rpx;
  249. margin-top: 25rpx;
  250. border-radius: 28rpx;
  251. background: linear-gradient(to right, #fccd90, #b6762f);
  252. line-height: 56rpx;
  253. text-align: center;
  254. color: #ffffff;
  255. font-size: 28rpx;
  256. }
  257. // 公司名
  258. .user-text {
  259. width: 446rpx;
  260. margin-top: 25rpx;
  261. color: #fff;
  262. font-size: 28rpx;
  263. line-height: 40rpx;
  264. text-align: center;
  265. white-space: nowrap;
  266. overflow: hidden;
  267. text-overflow: ellipsis;
  268. }
  269. .user-bg {
  270. width: 100%;
  271. }
  272. }
  273. .more {
  274. width: 750rpx;
  275. display: flex;
  276. justify-content: space-between;
  277. align-items: center;
  278. padding: 23rpx 25rpx;
  279. box-sizing: border-box;
  280. background: #fff;
  281. .more-right {
  282. font-size: 26rpx;
  283. line-height: 37rpx;
  284. margin-right: 10rpx;
  285. }
  286. .title {
  287. font-size: 32rpx;
  288. line-height: 45rpx;
  289. color: #333333;
  290. }
  291. .iconfont {
  292. font-size: 20rpx;
  293. vertical-align: middle;
  294. }
  295. }
  296. .order-wrap {
  297. background: #fff;
  298. .line {
  299. width: 702rpx;
  300. height: 1px;
  301. margin: 0 auto;
  302. background: #f0f0f0;
  303. }
  304. .order-nav {
  305. display: flex;
  306. justify-content: space-evenly;
  307. align-items: center;
  308. padding: 40rpx 0;
  309. .order-nav-item {
  310. display: flex;
  311. align-items: center;
  312. flex-direction: column;
  313. image {
  314. width: 56rpx;
  315. height: 56rpx;
  316. }
  317. text {
  318. font-size: 26rpx;
  319. line-height: 37rpx;
  320. margin-top: 8rpx;
  321. }
  322. }
  323. }
  324. }
  325. .place-order {
  326. width: 750rpx;
  327. display: flex;
  328. justify-content: space-between;
  329. align-items: center;
  330. padding: 23rpx 25rpx;
  331. box-sizing: border-box;
  332. background: #fff;
  333. margin-top: 20rpx;
  334. .place-left {
  335. .title {
  336. font-size: 28rpx;
  337. line-height: 40rpx;
  338. margin-left: 10rpx;
  339. }
  340. .iconfont {
  341. font-size: 36rpx;
  342. vertical-align: middle;
  343. }
  344. }
  345. .iconfont {
  346. font-size: 20rpx;
  347. }
  348. }
  349. .ws-service {
  350. width: 160rpx;
  351. height: 48rpx;
  352. margin: 40rpx auto 0;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. font-size: 22rpx;
  357. background: linear-gradient(to right, #fccd90, #b6762f);
  358. color: #fff;
  359. border-radius: 24rpx;
  360. .iconfont {
  361. font-size: 30rpx;
  362. margin-right: 6rpx;
  363. }
  364. }
  365. .badge {
  366. background-color: #ff0000;
  367. }
  368. </style>