index.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. <template>
  2. <view class="content" :class="hasShopiing?'':'bg-1'">
  3. <view class="content-body">
  4. <!-- 头部栏 -->
  5. <view class="header-box">
  6. <UniStatusBar></UniStatusBar>
  7. <view class="title flex align_center" :style="{height:(navHeight+'px')}">
  8. <u-image src="/static/logo-h.png" width="349" height='40'></u-image>
  9. <!-- 版本提示 -->
  10. <text class="version" v-if="showVersion">体验版</text>
  11. </view>
  12. </view>
  13. <!-- 浮动头部 -->
  14. <view class="header-box headerFixed" v-if="hasShopiing&&showFixed">
  15. <UniStatusBar></UniStatusBar>
  16. <view class="title flex align_center" :style="{height:(navHeight+'px')}">
  17. <view class="search-head" @click="toSearch">
  18. <uni-search-bar readonly radius="100" bg-color="#fff" placeholder="请输入商品名称/产品编码/原厂编码" clearButton="auto" cancelButton="none"/>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="cbody" :class="hasShopiing?'bg-0':''">
  23. <view :class="hasShopiing?'shopping':'body-box bg-blue'">
  24. <!-- 滚动区域 -->
  25. <view class="scroll-list" v-if="!hasShopiing">
  26. <scrollBox v-if="list.length&&!hasRedPacket" :list="list"></scrollBox>
  27. <scrollBox v-if="slist.length&&hasRedPacket" :list="slist"></scrollBox>
  28. </view>
  29. <!-- 保证金 -->
  30. <view class="notices flex align_center" v-if="bondRecord" @click="toPayBondAmount">
  31. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有一笔保证金待支付 ¥{{bondRecord.bondAmount}}</view>
  32. <!-- <text class="text">立即支付>></text> -->
  33. </view>
  34. <!-- 待取货提醒 -->
  35. <view class="notices flex align_center" v-if="!bondRecord&&orderTodo" @click="toOrder">
  36. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text class="text">立即处理>></text>
  37. </view>
  38. <!-- 去认证门店 -->
  39. <view class="notices flex" v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'">
  40. <!-- 门店审核不通过 -->
  41. <view class="flex justify_between align_center" v-if="storeApply&&storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'">
  42. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 门店认证资料审核不通过,请重新提交审核!</view> <text class="text" @click="toKnow">知道了</text>
  43. </view>
  44. <view class="flex justify_between align_center" v-else>
  45. <view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> {{storeApply&&storeApply.auditStatus=='WAIT'?'认证门店审核中':'您还未认证门店'}}</view> <text class="text" @click="authStore">{{storeApply&&storeApply.auditStatus=='WAIT'?'查看':'去认证'}}</text>
  46. </view>
  47. </view>
  48. <!-- 名片 -->
  49. <view class="userCard flex align_center justify_between" v-if="!hasShopiing">
  50. <view class="userCard-info flex align_center">
  51. <view>
  52. <u-image shape='circle' v-if="!hasLogin" src="/static/def_personal_avatar.png" width="90" height="90"></u-image>
  53. <u-image shape='circle' v-else :src="avatarUrl||'/static/def_personal_avatar.png'" width="90" height="90"></u-image>
  54. </view>
  55. <view class="user-info" @click="toUser">
  56. <view v-if="!hasLogin" style="font-size: 40rpx;">
  57. 请点击登录
  58. </view>
  59. <view v-else>
  60. <view class="user-name">{{userInfo.userNameCN || userInfo.mobile}}</view>
  61. <view v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'">
  62. <u-tag text="个人用户" mode="dark" type="warning" shape="circle" size="mini" />
  63. </view>
  64. <view v-else>{{userInfo.orgName}}</view>
  65. </view>
  66. </view>
  67. </view>
  68. <view @click="toUser">
  69. <text v-if="hasLogin&&userInfo&&userInfo.sysUserFlag == '0'" class="user-rz">
  70. {{storeApply&&storeApply.auditStatus=='WAIT'?'认证门店审核中':'认证成为门店'}}
  71. </text>
  72. <uni-icons type="arrowright" size="20" color="#999"></uni-icons>
  73. </view>
  74. </view>
  75. <!-- 搜索 -->
  76. <view class="search-head" v-if="hasShopiing" @click="toSearch">
  77. <uni-search-bar readonly radius="100" bg-color="#fff" placeholder="请输入商品名称/产品编码/原厂编码" clearButton="auto" cancelButton="none"/>
  78. </view>
  79. </view>
  80. <view :class="hasShopiing?'body-box1':'body-box'">
  81. <!-- 扫描按钮 -->
  82. <view class="action-button flex" v-if="userInfo.sysUserFlag == '1'&&!hasShopiing">
  83. <view class="f1" @click="openTakeGood(1)">
  84. <view class="icons"><u-icon name="bianmachaxun" custom-prefix="custom-icon"></u-icon></view>
  85. <view class="tits">产品编码取货</view>
  86. </view>
  87. <view class="f2" @click="openTakeGood(0)">
  88. <view class="icons"><u-icon name="saoma" custom-prefix="custom-icon"></u-icon></view>
  89. <view class="tits">二维码/条形码取货</view>
  90. </view>
  91. </view>
  92. <!-- banner -->
  93. <view class="banner">
  94. <u-swiper mode="dot" bg-color="" img-mode="widthFix" @click="clickBanner" :interval="3000" :height="hasShopiing?280:350" :list="imgList"></u-swiper>
  95. </view>
  96. <!-- 快捷导航 -->
  97. <view class="quick-nav pa-box" v-if="hasShopiing&&navList.length">
  98. <iconItemsList :list="navList" type="img" :isLogin="true" :sysUserFlag="userInfo.sysUserFlag" :iconSize="45" @callback="onNavFun"></iconItemsList>
  99. </view>
  100. <!-- 产品分类 -->
  101. <view class="ptype-nav pa-box" v-if="hasShopiing&&productTypeList.length">
  102. <swiper class="swiper" :style="{height:navHeight==44?'160px':'160px'}" @change="e=>{currentPtypeDot=e.detail.current}">
  103. <swiper-item v-for="(item, idx) in productTypeList" :index="idx" :key="item.id">
  104. <iconItemsList :isLogin="hasLogin" circle :sysUserFlag="userInfo.sysUserFlag" :list="item.list" type="img"></iconItemsList>
  105. </swiper-item>
  106. </swiper>
  107. <view class="indicator-dots" v-if="productTypeList.length>1">
  108. <view v-for="(item,idx) in productTypeList" :key="idx" :class="currentPtypeDot==idx?'indicator-dots-active':''" ></view>
  109. </view>
  110. </view>
  111. <!-- 产品列表 -->
  112. <view class="product-box" v-if="hasShopiing && totalhotPage>0">
  113. <u-divider bg-color="" half-width="0" color="#666" use-slot :fontSize="28">
  114. <image style="width: 16px;height:16px;" src="../../static/hot.png"></image>
  115. <text style="margin: 0 5px;font-weight: bold;">热门推荐</text>
  116. <image style="width: 16px;height:16px;" src="../../static/hot.png"></image>
  117. </u-divider>
  118. <view class="product-list">
  119. <!-- 产品列表 -->
  120. <productItem
  121. v-for="(item,index) in productList"
  122. :key="index"
  123. :list="item"
  124. :index="index"
  125. :itemWidth="(screenWidth-25)*0.5"
  126. :gap="5"
  127. :isLogin="hasLogin"
  128. :sysUserFlag="userInfo.sysUserFlag"
  129. ></productItem>
  130. <view style="padding: 50upx 0;">
  131. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="totalhotPage==0 && status!='loading'" mode="list"></u-empty>
  132. <u-loadmore v-else color="#999" :fontSize="24" :status="status" />
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. <!-- 扫描记录 -->
  138. <view class="list-box" v-if="!hasShopiing">
  139. <!-- 扫描记录 -->
  140. <u-cell-group :border="false">
  141. <u-cell-item title="VIN查询历史" @click="toAllRecord" :title-style="{fontSize:'1em'}" value="全部">
  142. <u-icon slot="icon" size="32" color="#066cff" style="margin-right: 0.3em;" name="order"></u-icon>
  143. </u-cell-item>
  144. </u-cell-group>
  145. <u-cell-group :border="false" v-if="hasLogin">
  146. <u-cell-item v-for="item in vinList"
  147. @click="toChoosePart(item)"
  148. :key="item.id"
  149. :title="item.vinCode"
  150. :title-style="{fontSize:'1em'}"
  151. :label="userInfo&&userInfo.sysUserFlag == '0' ? item.createDate : (item.brandName +' '+item.modelName)">
  152. <text slot="icon"></text>
  153. </u-cell-item>
  154. <view style="padding: 20upx;">
  155. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="vinList.length==0 && status!='loading'" mode="list"></u-empty>
  156. <u-loadmore v-if="status=='loading'" :status="status" />
  157. </view>
  158. </u-cell-group>
  159. <view class="des" v-if="vinList.length&&hasLogin">仅展示最近5条记录,点击“全部”查看更多</view>
  160. <view class="des" v-if="!hasLogin">请登录后查看历史记录</view>
  161. </view>
  162. </view>
  163. </view>
  164. <!-- tab栏 -->
  165. <u-tabbar :list="vuex_tabBarList" :mid-button-size="80" :before-switch="beforeSwitch" :midButton="vuex_tabBarList.length==5"></u-tabbar>
  166. </view>
  167. </template>
  168. <script>
  169. import {
  170. mapState,
  171. mapMutations,
  172. } from 'vuex'
  173. import scrollBox from '@/components/scrollBox.vue'
  174. import UniStatusBar from '@/components/uni-status-bar/uni-status-bar.vue'
  175. import iconItemsList from '@/components/icon-items-list/icon-items-list.vue'
  176. import productItem from './productItem.vue'
  177. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty, getProductfindByScanCode, queryQplsConfig } from '@/api/shelf.js'
  178. import { xprhStoreApplyRead } from '@/api/xprh.js'
  179. import { findCurrentRewardRule } from '@/api/rewardRule.js'
  180. import { listLookUp, getLookUpDatas, getCurrUserInfo } from '@/api/data.js';
  181. import { scanVinLogQueryRoll, getScanVinLogList, getScanGetMaxQty }from '@/api/car.js'
  182. import { shopBannerList } from '@/api/video.js'
  183. import { getRewardRollList } from '@/api/rewardRule.js'
  184. import { getShopStatus, getCartCount } from '@/api/cart.js'
  185. import { getShopCategory, getShopProductList } from '@/api/shop.js'
  186. import { openWebView, clickTab, toAuthStore, clickBannerList, toLogin } from "@/utils/index.js"
  187. export default {
  188. components: {
  189. iconItemsList, // 图标网格
  190. scrollBox, // 无缝滚动组件
  191. UniStatusBar, // 状态栏组件
  192. productItem // 产品列表
  193. },
  194. data() {
  195. const _this = this
  196. return {
  197. status: 'loading',
  198. noDataText: '暂无数据',
  199. hasShopiing: true, // 是否开通商城
  200. bondRecord: null, // 保证金
  201. list:[], // 扫描记录滚动
  202. slist:[], // 红包滚动
  203. vinList: [], // 扫描记录
  204. orderTodo: null, // 待取货的货架订单信息
  205. avatarUrl:'', // 用户图像
  206. navHeight: '44', // 头部高度
  207. scanMaxNums: 10, // 扫描VIN仅限10次
  208. carouselList: [] ,// 修理厂促销活动列表
  209. productTypeList: [], // 产品分类
  210. currentPtypeDot: 0, // 当前产品分类页
  211. screenWidth: 325, // 屏幕宽度
  212. productList:[], // 热门产品
  213. hotProductPageNo: 1 ,// 热门产品页码
  214. hotProductpageSize:10, // 热门产品每页数量
  215. totalhotPage: 0, // 热门产品总页数
  216. showFixed: false, // 是否显示浮动头部
  217. isCheckLogin:false, // 是否正在检查登录
  218. }
  219. },
  220. computed: {
  221. ...mapState(['hasLogin','vuex_vinScanNums','vuex_tabBarList']),
  222. // 显示开发版本信息
  223. showVersion () {
  224. const baseUrl = getApp().globalData.baseUrl
  225. return baseUrl.indexOf(".test.") >= 0 || baseUrl.indexOf('192.168') >=0
  226. },
  227. // 是否有数字货架
  228. hasShelf(){
  229. return this.$store.state.vuex_storeShelf
  230. },
  231. // 登录用户信息
  232. userInfo(){
  233. return this.$store.state.vuex_userInfo
  234. },
  235. // 是否有门店申请信息
  236. storeApply(){
  237. return this.$store.state.vuex_storeAuthInfo || null
  238. },
  239. // 是否有红包
  240. hasRedPacket(){
  241. const rule = this.$store.state.vuex_rewardRule
  242. return rule&&rule.ruleStatus == 'release'
  243. },
  244. // banner 图片列表
  245. imgList(){
  246. let list = [
  247. {
  248. image: '/static/banner1.jpg',
  249. activeType: ''
  250. }
  251. ]
  252. const newList = []
  253. // 红包
  254. if(this.hasRedPacket&&this.hasShelf){
  255. newList.push(
  256. {
  257. image: '/static/banner2.jpg',
  258. activeType: 'redPacket'
  259. })
  260. }
  261. return this.carouselList.length>0 ? newList.concat(this.carouselList) : list.concat(newList)
  262. },
  263. // 快捷导航
  264. navList(){
  265. const list = [
  266. {
  267. id:'n0',
  268. auth: this.hasLogin,
  269. ignoreAuth: false,
  270. icon:'/static/nav_icon1.jpg',
  271. name: '产品编码取货',
  272. color:'#056cd9',
  273. url: 'openTakeGood1',
  274. target: 'fun'
  275. },
  276. {
  277. id:'n1',
  278. auth: this.hasLogin,
  279. ignoreAuth: false,
  280. icon:'/static/nav_icon2.jpg',
  281. name: '二维/条码取货',
  282. color:'#f44336',
  283. url:'openTakeGood0',
  284. target: 'fun'
  285. },
  286. {
  287. id:'n3',
  288. auth: true,
  289. ignoreAuth: true,
  290. icon:'/static/nav_icon3.jpg',
  291. name: '视频教程',
  292. color:'#03a9f4',
  293. url:'/pagesB/videos/index',
  294. target: 'page'
  295. },
  296. {
  297. id:'n2',
  298. auth: this.hasLogin,
  299. ignoreAuth: true,
  300. icon:'/static/nav_icon4.jpg',
  301. name: 'VIN查询历史',
  302. color:'#ff9800',
  303. url:'/pagesA/vinRecord/vinRecord',
  304. target: this.hasLogin ? 'page' : 'fun'
  305. }
  306. ]
  307. return list
  308. }
  309. },
  310. onReady() {
  311. // 获取导航栏高度
  312. const res = uni.getSystemInfoSync()
  313. this.screenWidth = res.windowWidth
  314. const system = res.platform
  315. if (system === 'android') {
  316. this.navHeight = 48
  317. } else if (system === 'ios') {
  318. this.navHeight = 44
  319. }
  320. },
  321. onLoad() {
  322. this.orderTodo = null
  323. this.bondRecord = null
  324. this.vinList = []
  325. // 视频类型
  326. this.getLookUpList('CONTENT_CATEGORY', 'vuex_videoTypeList');
  327. // 检测是否登录
  328. this.isCheckLogin = true
  329. this.$store.dispatch('checkLogin',(isLogin)=>{
  330. this.isCheckLogin = false
  331. // 获取数据字典
  332. this.getListLookUp();
  333. // 获取支付,收款方式
  334. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  335. // 价格类型
  336. this.getLookUpList('PRICE_SHOW_TYPE', 'vuex_priceTypeList');
  337. // 初始化页面
  338. this.pageInit(0)
  339. })
  340. // 刷新首页数据
  341. uni.$on("refashHome",()=>{
  342. this.pageInit(2)
  343. })
  344. // 刷新购物车
  345. uni.$on("refashCart",()=>{
  346. this.cartCount()
  347. })
  348. },
  349. // 页面卸载
  350. onUnload() {
  351. uni.$off('refashHome')
  352. uni.$off('refashProm')
  353. uni.$off('refashCart')
  354. },
  355. onHide() {
  356. // 用户头像
  357. this.avatarUrl = uni.getStorageSync('userPhoto');
  358. // 重新刷新
  359. if(!this.isCheckLogin){
  360. this.pageInit(1)
  361. }
  362. },
  363. // 下拉刷新
  364. onPullDownRefresh(){
  365. this.pageInit(2)
  366. setTimeout(function () {
  367. uni.stopPullDownRefresh();
  368. }, 1000);
  369. },
  370. onShareAppMessage() {},
  371. // 页面滚动
  372. onPageScroll(e) {
  373. this.showFixed = e.scrollTop > 120
  374. },
  375. // 滚动到底部,加载热门产品
  376. onReachBottom() {
  377. if(this.hasShopiing && this.hotProductPageNo < this.totalhotPage){
  378. this.hotProductPageNo++
  379. this.getProductList()
  380. }
  381. },
  382. methods: {
  383. // 去认证
  384. authStore(){
  385. uni.navigateTo({
  386. url: '/pages/storeManage/storeAuth'
  387. })
  388. },
  389. // 初始化页面
  390. pageInit(flag){
  391. // 已登录
  392. if(this.hasLogin){
  393. // 已认证用户
  394. if(this.userInfo.sysUserFlag == '1'){
  395. // 查询是否有数字货架
  396. this.getStoreShelf(flag)
  397. }else{// 游客
  398. // 获取扫描次数
  399. this.$store.dispatch("getScanNums")
  400. // 获取最大扫描次数
  401. this.getMaxQty()
  402. // 查询门店认证信息
  403. this.findLastApply()
  404. // 获取扫描记录
  405. this.getVinLog()
  406. if(this.hasShopiing){
  407. this.showShopPage(flag)
  408. }else{
  409. this.showNoShopPage()
  410. }
  411. }
  412. }else{
  413. // 未登录
  414. this.hasShopiing = true
  415. // 隐藏促销模块
  416. this.hidePromoTab()
  417. if(this.hasShopiing){
  418. this.showShopPage(flag)
  419. }else{
  420. this.showNoShopPage()
  421. }
  422. }
  423. },
  424. // 查询是否支持数字货架, flag: true 再次刷新,false 首次加载,只加载一次
  425. getStoreShelf(flag){
  426. findStoreShelf().then(res => {
  427. this.$store.state.vuex_storeShelf = res.data;
  428. // 有数字货架
  429. if(res.data){
  430. // 查询是否有商城
  431. this.getHasShopping(flag)
  432. // 只需加载一次
  433. if(flag==0){
  434. // 更新用户信息
  435. this.getCurrUserInfo()
  436. // 保证金查询
  437. this.getShelfBWPayRecord()
  438. // 获取订单信息
  439. this.shelfGetTotalWaitQty()
  440. // 获取价格权限配置
  441. this.getPriceCofig()
  442. }
  443. }else{
  444. // 没有数字货架,隐藏促销模块
  445. this.hidePromoTab()
  446. }
  447. })
  448. },
  449. // 最新用户信息
  450. getCurrUserInfo(){
  451. getCurrUserInfo().then(res => {
  452. if(res.data){
  453. this.$store.state.vuex_userInfo.userNameCN = res.data.name;
  454. this.$store.state.vuex_userInfo.mobile = res.data.mobile;
  455. this.$store.state.vuex_userInfo.adminId = res.data.id;
  456. this.$store.state.vuex_userPhoto = res.data.photo;
  457. uni.setStorageSync('userPhoto', res.data.photo);
  458. }
  459. })
  460. },
  461. // 获取价格配置
  462. getPriceCofig(){
  463. const data = this.$store.state.vuex_storeShelf
  464. queryQplsConfig({shelfSn: data.shelfSn}).then(res => {
  465. this.$store.state.vuex_configPrice = res.data || null
  466. })
  467. },
  468. // 商城信息, flag: true 再次刷新,false 只加载一次
  469. getHasShopping(flag){
  470. getShopStatus().then(res => {
  471. this.hasShopiing = res.data && res.data.paramValue == 1
  472. // 有商城
  473. if(this.hasShopiing){
  474. this.showShopPage(flag)
  475. }else{
  476. // 没有商城
  477. this.showNoShopPage(flag)
  478. }
  479. // 查询红包活动
  480. this.getRedPacketRule()
  481. })
  482. },
  483. // 显示开通商城的页面
  484. showShopPage(flag){
  485. // 隐藏tab 视频,显示tab购物车
  486. if(this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1'){
  487. // 显示促销模块
  488. this.showPromoTab()
  489. this.cartCount()
  490. }else{
  491. this.$store.state.vuex_cartTotal = 0
  492. this.showCatTab()
  493. }
  494. // 获取轮播数据,包括促销活动
  495. this.getCarousel(1)
  496. // 商品分类
  497. this.getGoodType(flag)
  498. // 获取推荐产品
  499. this.getHotProductList(flag)
  500. },
  501. // 显示未没有开通商城的界面
  502. showNoShopPage(flag){
  503. this.productTypeList = []
  504. this.productList = []
  505. // 获取轮播数据,包括促销活动
  506. this.getCarousel(0)
  507. // 隐藏促销模块
  508. this.hidePromoTab()
  509. // 隐藏tab 购物车,显示tab视频
  510. this.showVideoTab()
  511. // 滚动扫描记录
  512. this.getScrollLog()
  513. // 获取扫描记录
  514. if(this.hasLogin){
  515. this.getVinLog()
  516. }
  517. },
  518. // 购物车数量
  519. cartCount(){
  520. getCartCount({}).then(res => {
  521. if(res.status == 200){
  522. this.$store.state.vuex_cartTotal = res.data?res.data.qty:0
  523. this.showCatTab()
  524. }
  525. })
  526. },
  527. // 商品一级分类
  528. getGoodType(flag){
  529. this.productTypeList = []
  530. getShopCategory({categoryLevel: 1}).then(res => {
  531. const list = res.data || []
  532. const ret = []
  533. list.forEach(item => {
  534. ret.push({
  535. id: item.id,
  536. categorySn: item.categorySn,
  537. auth: true,
  538. ignoreAuth: false,
  539. name: item.categoryName,
  540. icon: item.iconUrl,
  541. url: '/pagesB/shopiing/shopProduct?clzId='+item.categorySn+'&clzName='+item.categoryName+"&shopCategoryCount="+item.shopCategoryCount+'&shopProductCount='+item.shopProductCount,
  542. target: 'page'
  543. })
  544. })
  545. // 转成二维数组
  546. for(let i=0;i<ret.length;i=i+8){
  547. this.productTypeList.push({
  548. id: 'swiper-item-'+i,
  549. list: ret.slice(i,(i+8)>ret.length?ret.length:(i+8))
  550. })
  551. }
  552. })
  553. },
  554. // 商品列表查询
  555. getHotProductList(flag){
  556. console.log(flag)
  557. this.hotProductPageNo = 1
  558. // 不是show 刷新列表
  559. if(flag!=1){
  560. this.productList = []
  561. this.hotProductpageSize = 10
  562. }else{
  563. // 刷新列表
  564. let count = 0
  565. this.productList.forEach(item => {
  566. count += item.length
  567. })
  568. this.hotProductpageSize = count||10
  569. }
  570. this.getProductList(flag)
  571. },
  572. getProductList(flag){
  573. this.status = "loading"
  574. const dealerSn = this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1' ? this.$store.state.vuex_storeShelf.dealerSn : ''
  575. // 获取推荐产品
  576. getShopProductList({pageNo:this.hotProductPageNo,pageSize:this.hotProductpageSize,hotFlag:1, status: 1, dealerSn: dealerSn}).then(res => {
  577. if(res.status == 200){
  578. const list = res.data ? res.data.list : []
  579. list.map(item=>{
  580. const a = item.shopPromoProduct
  581. if(a){
  582. item.promoType = a.promoType
  583. item.resultValue = a.resultValue
  584. item.conditionValue = a.conditionValue
  585. item.discountType = a.discountType
  586. item.promoProductSn = a.promoProductSn
  587. item.promoSn = a.promoSn
  588. item.orginPrice = item.price
  589. // 特价
  590. if(item.promoType=='PROMO_PROD'){
  591. item.price = item.conditionValue
  592. }
  593. }
  594. item.priceStr = Number(item.price).toFixed(2).toString().split('.')
  595. delete item.shopPromoProduct
  596. })
  597. if(flag!=1){
  598. this.productList.push(list)
  599. }else{
  600. // 刷新
  601. this.productList = [list]
  602. }
  603. this.status = res.data.count>=this.list.length ? "nomore" : 'loadmore'
  604. // 判断是否最后一页
  605. const maxPages = Math.ceil(res.data.count / 10)
  606. this.totalhotPage = maxPages
  607. this.status = this.hotProductPageNo >= maxPages ? "nomore" : 'loadmore'
  608. this.noDataText = this.status == 'nomore' ? '没有更多了' : '更多商品'
  609. }else{
  610. this.status = "nomore"
  611. this.noDataText = res.message || '没有更多了'
  612. }
  613. })
  614. },
  615. // 获取上方滚动扫描记录
  616. getScrollLog(){
  617. scanVinLogQueryRoll({pageNo:1,pageSize:50}).then(res => {
  618. this.list = res.data.list || []
  619. this.list.map(item => {
  620. item.placeText = item.userName + '刚刚扫描了一个VIN'
  621. })
  622. })
  623. },
  624. // 获取当前门店扫描记录
  625. getVinLog(){
  626. this.vinList = []
  627. this.status = "loading"
  628. // VISITOR:游客,EMPLOYEE:雇员
  629. getScanVinLogList({ pageNo:1, pageSize:5, identifyType: this.userInfo.identifyType }).then(res => {
  630. this.vinList = res.data&&res.data.list || []
  631. this.vinList = this.vinList.filter(item => item.vinCode)
  632. this.status = 'nomore'
  633. })
  634. },
  635. // tab单击
  636. beforeSwitch(index){
  637. const row = this.$store.state.vuex_tabBarList[index] // 当前tab
  638. const isNoAuth = this.userInfo ? this.userInfo.sysUserFlag == '0' : false // 是否认证门店
  639. return clickTab(row,this.hasLogin,isNoAuth,this.vuex_vinScanNums < this.vuex_scanMaxNums)
  640. },
  641. // 去搜索产品
  642. toSearch(event){
  643. if(this.hasLogin){
  644. // 游客去认证
  645. if(this.userInfo.sysUserFlag == '0'){
  646. toAuthStore()
  647. }else{
  648. uni.navigateTo({
  649. url:'/pagesB/shopiing/searchProduct?queryWord='+event.value+'&clzId='
  650. })
  651. }
  652. }else{
  653. toLogin()
  654. }
  655. },
  656. // 轮播图片
  657. getCarousel(flag){
  658. this.carouselList = []
  659. // 获取所有促销活动数据
  660. shopBannerList({promoFlag:flag}).then(res => {
  661. if(res.status == 200){
  662. res.data&&res.data.map(item => {
  663. item.image = item.imageUrl
  664. })
  665. this.carouselList = res.data
  666. }
  667. })
  668. },
  669. // 快速导航单击
  670. onNavFun(item){
  671. if(item.auth){
  672. // 非游客
  673. if(this.userInfo.sysUserFlag == '1'){
  674. // 编码取货
  675. if(item.url=='openTakeGood1'){
  676. this.openTakeGood(1)
  677. }
  678. // 扫码取货
  679. if(item.url=='openTakeGood0'){
  680. this.openTakeGood(0)
  681. }
  682. }else{
  683. // 去认证
  684. toAuthStore()
  685. }
  686. }else{
  687. toLogin()
  688. }
  689. },
  690. // 获取数据字典
  691. getListLookUp() {
  692. const _this = this;
  693. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  694. if (res.status == 200) {
  695. _this.$store.state.vuex_allLookUp = res.data;
  696. }
  697. });
  698. },
  699. // 或某一项字典列表,参数code
  700. getLookUpList(code, vuexKey) {
  701. getLookUpDatas({ type: code }).then(res => {
  702. if (res.status == 200) {
  703. this.$store.state[vuexKey] = res.data || [];
  704. }
  705. });
  706. },
  707. // 获取最大扫描数
  708. getMaxQty(){
  709. getScanGetMaxQty().then(res => {
  710. this.scanMaxNums = res.data || 10
  711. this.$store.state.vuex_scanMaxNums = this.scanMaxNums
  712. })
  713. },
  714. // 获取最新申请门店
  715. findLastApply(){
  716. const mobile = this.userInfo.mobile
  717. this.$store.dispatch('getSotreAuth',mobile)
  718. },
  719. // 知道审核不通过
  720. toKnow(){
  721. uni.showLoading({
  722. title: "正在提交"
  723. })
  724. xprhStoreApplyRead({sn:this.storeApply.applySn}).then(res => {
  725. if(res.status == 200){
  726. this.findLastApply()
  727. }
  728. uni.hideLoading()
  729. })
  730. },
  731. // 待取货数量合计
  732. shelfGetTotalWaitQty(){
  733. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  734. if(res.status == 200){
  735. this.orderTodo = res.data;
  736. }
  737. })
  738. },
  739. // 货架订单列表
  740. toOrder(){
  741. if(this.hasShelf){
  742. uni.navigateTo({
  743. url: "/pagesA/digitalShelf/orderList"
  744. })
  745. }else{
  746. uni.showToast({
  747. icon:'none',
  748. title: '门店没有关联数字货架,无法使用此功能!'
  749. })
  750. }
  751. },
  752. // 显示购物车tab
  753. showCatTab(){
  754. const videoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '视频')
  755. const catIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '购物车')
  756. if(catIndex<0 && videoIndex >= 0){
  757. // 替换视频为购物车
  758. this.$store.state.vuex_tabBarList.splice(videoIndex,1,{
  759. "pagePath": "/pages/cart/index",
  760. "iconPath": "/static/tab/tab_cart_normal.png",
  761. "selectedIconPath": "/static/tab/tab_cart_pressed.png",
  762. "text": "购物车",
  763. 'customIcon': false,
  764. 'count': this.$store.state.vuex_cartTotal,
  765. 'isDot': false
  766. })
  767. }
  768. // 购物车已存在
  769. if(catIndex>=0){
  770. this.$store.state.vuex_tabBarList[catIndex].count = this.$store.state.vuex_cartTotal
  771. }
  772. },
  773. // 显示视频tab,隐藏购物车
  774. showVideoTab(){
  775. const videoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '视频')
  776. const catIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '购物车')
  777. if(videoIndex<0 && catIndex >= 0){
  778. // 替换购物车为视频
  779. this.$store.state.vuex_tabBarList.splice(catIndex,1,{
  780. "pagePath": "/pages/videos/index",
  781. "iconPath": "/static/tab/tab_video_normal.png",
  782. "selectedIconPath": "/static/tab/tab_video_pressed.png",
  783. "text": "视频",
  784. 'customIcon': false,
  785. })
  786. }
  787. },
  788. // 显示促销模块
  789. showPromoTab(){
  790. // 添加促销模块
  791. const promoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '促销')
  792. if(promoIndex<0){
  793. this.$store.state.vuex_tabBarList.splice(1,0,{
  794. "pagePath": "/pages/promo/index",
  795. "iconPath": "/static/tab/tab_promo_normal.png",
  796. "selectedIconPath": "/static/tab/tab_promo_pressed.png",
  797. "text": "促销",
  798. 'customIcon': false,
  799. })
  800. }
  801. // 居中透出显示扫描按钮
  802. const scanTab = this.$store.state.vuex_tabBarList.find(item => item.text == '扫描VIN')
  803. if(scanTab){
  804. scanTab.iconPath = "/static/tab/tab_scan_mid.png"
  805. scanTab.midButton = true
  806. }
  807. },
  808. // 隐藏促销模块
  809. hidePromoTab(){
  810. // 删除促销模块
  811. const promoIndex = this.$store.state.vuex_tabBarList.findIndex(item => item.text == '促销')
  812. if(promoIndex > -1){
  813. this.$store.state.vuex_tabBarList.splice(promoIndex,1)
  814. }
  815. // 扫描按钮不局中
  816. const scanTab = this.$store.state.vuex_tabBarList.find(item => item.text == '扫描VIN')
  817. if(scanTab){
  818. scanTab.iconPath = "/static/tab/tab_scan_normal.png"
  819. scanTab.midButton = false
  820. }
  821. },
  822. // 查询是有红包活动
  823. getRedPacketRule(){
  824. findCurrentRewardRule().then(res => {
  825. this.$store.state.vuex_rewardRule = res.data;
  826. // 商城未开通时调用
  827. if(res.data && !this.hasShopiing){
  828. this.getRedScroll()
  829. }
  830. })
  831. },
  832. // 红包奖励信息
  833. getRedScroll(){
  834. getRewardRollList({pageNo:1,pageSize:50}).then(res => {
  835. this.slist = res.data || []
  836. this.slist.map(item => {
  837. item.placeText = item.userName + '刚刚得到了'+item.totalRewardAmount+'元 红包奖励'
  838. })
  839. })
  840. },
  841. // 获取保证金金额
  842. getShelfBWPayRecord(){
  843. const data = this.$store.state.vuex_storeShelf
  844. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  845. console.log(res,'获取保证金金额')
  846. this.bondRecord = res.data
  847. })
  848. },
  849. // 保证金支付
  850. toPayBondAmount(){},
  851. openTakeGood(index){
  852. // 已有数字货架
  853. if(this.hasShelf){
  854. this.clickAction(index)
  855. }else{
  856. uni.showToast({
  857. icon:'none',
  858. title: '门店没有关联数字货架,无法使用此功能!'
  859. })
  860. }
  861. },
  862. // 选择取货方式
  863. clickAction(index){
  864. const shelfSn = this.hasShelf.shelfSn
  865. const _this = this
  866. // 扫描
  867. if(index == 0){
  868. uni.scanCode({
  869. success: function (ret) {
  870. const params = {
  871. codeType: ret.scanType == 'QR_CODE' ? 0 : 1
  872. }
  873. // 二维码
  874. if(ret.scanType == 'QR_CODE'){
  875. const result = ret.result.split("&")
  876. params.productSn = result[2] // 产品编码sn
  877. }else{
  878. params.qrCode = ret.result
  879. }
  880. uni.showLoading({
  881. title: "正在查询产品..."
  882. })
  883. // 确认取货
  884. getProductfindByScanCode(params).then(res => {
  885. if(res.status == 200 && res.data){
  886. if(res.data.currentInven){
  887. const billSource = ret.scanType == 'QR_CODE' ? 'qr_code': 'bar_code'
  888. const retData = Object.assign({shelfSn: shelfSn, billSource: billSource},res.data)
  889. _this.$store.state.vuex_tempData = retData
  890. uni.navigateTo({
  891. url: '/pagesA/queryByCode/confirmQh'
  892. })
  893. }else{
  894. uni.showModal({
  895. title: '提示',
  896. content: '产品库存为0,无法取货!',
  897. confirmText: '好的',
  898. showCancel: false
  899. })
  900. }
  901. }else{
  902. uni.showModal({
  903. title: '提示',
  904. content: '产品不属于此货架,请重新扫描!',
  905. confirmText: '好的',
  906. showCancel: false
  907. })
  908. }
  909. uni.hideLoading()
  910. })
  911. }
  912. });
  913. }else{
  914. // 按编码搜索
  915. uni.navigateTo({
  916. url: '/pagesA/queryByCode/queryByCode'
  917. })
  918. }
  919. },
  920. // 单击banner
  921. clickBanner(index){
  922. clickBannerList(this.imgList[index],this.hasLogin,this.userInfo&&this.userInfo.sysUserFlag == '1')
  923. },
  924. // 查看扫描VIN记录
  925. toAllRecord(){
  926. if(this.hasLogin){
  927. uni.navigateTo({
  928. url: "/pagesA/vinRecord/vinRecord"
  929. })
  930. }else{
  931. toLogin()
  932. }
  933. },
  934. // 查看用户信息
  935. toUser(){
  936. if(this.hasLogin){
  937. if(this.userInfo.sysUserFlag == '1'){
  938. // 用户详细信息
  939. uni.navigateTo({
  940. url: '/pages/personData/personData'
  941. })
  942. }else{
  943. // 或 门店认证
  944. toAuthStore()
  945. }
  946. }else{
  947. toLogin()
  948. }
  949. },
  950. // 选择配件
  951. toChoosePart(item){
  952. item.text = item.modelInfo
  953. uni.navigateTo({
  954. url: "/pagesA/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))+'&type=log'
  955. })
  956. },
  957. }
  958. }
  959. </script>
  960. <style lang="less">
  961. page{
  962. background-color: #ffffff;
  963. }
  964. .bg-0{
  965. position: relative;
  966. > view{
  967. z-index:1;
  968. position: relative;
  969. }
  970. &::after{
  971. /* 这个伪类的作用就是一个圆弧的背景色 */
  972. width: 130%;
  973. height: 30vh;
  974. position: absolute;
  975. /*设置水平居中*/
  976. left: -15%;
  977. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  978. top: 0;
  979. /*层叠顺序,最底层显示*/
  980. content: '';
  981. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  982. background: linear-gradient(to bottom, #86defa, #ffffff);
  983. }
  984. }
  985. .bg-1{
  986. background-image: linear-gradient(#86defa 0%,#cdeff9 20%,#ffffff 30%);
  987. }
  988. .content {
  989. margin: 0;
  990. padding: 0;
  991. display: flex;
  992. flex-direction: column;
  993. .content-body{
  994. flex-grow: 1;
  995. }
  996. .header-box{
  997. z-index: 5;
  998. padding: 0em 1em;
  999. background: #066cff;
  1000. .title{
  1001. padding: 0;
  1002. }
  1003. .version{
  1004. color: #FFEB3B;
  1005. font-size: 0.8em;
  1006. margin-left: 1em;
  1007. }
  1008. }
  1009. .headerFixed{
  1010. padding: 0 0.5rem;
  1011. width: 100%;
  1012. z-index: 10;
  1013. left: 0;
  1014. top:0;
  1015. position: fixed;
  1016. background: #066cff;
  1017. /deep/ .uni-searchbar{
  1018. padding: 0;
  1019. .uni-searchbar__box{
  1020. height: 30px;
  1021. }
  1022. }
  1023. }
  1024. .cbody{
  1025. flex-grow: 1;
  1026. overflow-y: auto;
  1027. overflow-x: hidden;
  1028. .notices{
  1029. padding: 0.5em 0 0;
  1030. font-size: 0.9em;
  1031. margin-top: 0.5rem;
  1032. view{
  1033. color: #ffaf46;
  1034. flex-grow: 1;
  1035. }
  1036. .text{
  1037. color: #ffffff;
  1038. margin-left: 1em;
  1039. }
  1040. }
  1041. .pa-box{
  1042. background: #fff;
  1043. border-radius: 6px;
  1044. margin: 10px 0;
  1045. padding: 10px 0;
  1046. border: 1px solid #eee;
  1047. }
  1048. .product-box{
  1049. margin: 10px 0;
  1050. }
  1051. .ptype-nav{
  1052. position: relative;
  1053. .indicator-dots{
  1054. width: 100%;
  1055. height: 3px;
  1056. display: flex;
  1057. align-items: center;
  1058. justify-content: center;
  1059. position: absolute;
  1060. left: 0;
  1061. bottom:5px;
  1062. }
  1063. .indicator-dots > view{
  1064. width: 10px;
  1065. height: 3px;
  1066. background: #e7e7e7;
  1067. display: inline-block;
  1068. }
  1069. .indicator-dots >.indicator-dots-active{
  1070. background: #00aaff;
  1071. }
  1072. }
  1073. }
  1074. .body-box{
  1075. padding: 0em 1em 0.8em;
  1076. z-index: 4;
  1077. .banner{
  1078. margin-top: 20rpx;
  1079. }
  1080. .action-button{
  1081. padding:40upx 0 0 0;
  1082. justify-content: space-between;
  1083. > view{
  1084. display: flex;
  1085. align-items: center;
  1086. color: #fff;
  1087. border-radius: 10rpx;
  1088. width: 49%;
  1089. padding: 6rpx 0;
  1090. box-shadow: 0rem 0.3rem 0.5rem #d9dada;
  1091. }
  1092. .f1{
  1093. background: #2196f3;
  1094. }
  1095. .f2{
  1096. background: #FF9800;
  1097. }
  1098. .icons{
  1099. font-size: 50rpx;
  1100. color: #fff;
  1101. width: 80rpx;
  1102. height: 80rpx;
  1103. text-align:center;
  1104. display: flex;
  1105. align-items: center;
  1106. flex-direction: column;
  1107. justify-content: center;
  1108. }
  1109. .tits{
  1110. font-size:28rpx;
  1111. }
  1112. }
  1113. }
  1114. .body-box1{
  1115. padding: 0em 10px 0.8em;
  1116. }
  1117. .bg-blue{
  1118. position: relative;
  1119. z-index: 1;
  1120. > view{
  1121. z-index: 100;
  1122. position: relative;
  1123. }
  1124. &::after{
  1125. /* 这个伪类的作用就是一个圆弧的背景色 */
  1126. width: 130%;
  1127. height: 100%;
  1128. position: absolute;
  1129. /*设置水平居中*/
  1130. left: -15%;
  1131. /* 之所以left:20%,是因为width:140%,若width:160%,那么left:30%才能水平居中 */
  1132. top: -10%;
  1133. /*层叠顺序,最底层显示*/
  1134. content: '';
  1135. border-radius: 0 0 50% 50%;
  1136. /*分别对应 左上 右上 右下 左下 可以修改成其它颜色*/
  1137. background: linear-gradient(to bottom, #066cff, #056bf9);
  1138. }
  1139. .userCard{
  1140. position:relative;
  1141. left:0;
  1142. bottom:-0.8rem;
  1143. padding: 0.5rem;
  1144. background: #fff;
  1145. border-radius: 0.8rem;
  1146. box-shadow: 0rem 0.3rem 0.5rem #bcdede;
  1147. .userCard-info{
  1148. flex-grow:1;
  1149. > view{
  1150. &:last-child{
  1151. margin-left: 0.5em;
  1152. line-height: 1.5em;
  1153. .user-name{
  1154. font-size: 1rem;
  1155. }
  1156. >view{
  1157. padding: 0.2em;
  1158. }
  1159. }
  1160. }
  1161. .user-info{
  1162. flex-grow:1;
  1163. }
  1164. }
  1165. .user-rz{
  1166. font-size: 0.8rem;
  1167. color:#58aff5;
  1168. }
  1169. }
  1170. }
  1171. .shopping{
  1172. padding: 0;
  1173. .notices{
  1174. padding: 0.5em 10px 0;
  1175. margin-top: 0.2rem;
  1176. .text{
  1177. color: #066cff;
  1178. }
  1179. }
  1180. }
  1181. .list-box{
  1182. padding: 0 1em;
  1183. overflow: auto;
  1184. .des{
  1185. text-align: center;
  1186. padding: 1em 0;
  1187. color: #999;
  1188. font-size: 0.8em;
  1189. }
  1190. }
  1191. }
  1192. </style>