shop.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view class="box">
  3. <view class="topbox">
  4. <view class="sstop">
  5. <image src="../../static/timg/icon_search@2x.png" mode="" class="sstopimg"></image>
  6. <input type="text" v-model="name" placeholder="请输入商品名称" class="sstopInput" @confirm="ssList">
  7. <image src="../../static/img/icon_close.png" mode="" @click="empty" v-if="inputChShow" class="inputCh"></image>
  8. </view>
  9. <scroll-view scroll-x="true" class="scroll-Y" >
  10. <view class="classificationBox">
  11. <view class="classification" v-for="(item,index) in categoryList" @click="topClick(index,item)">
  12. <view class="classificationName" :class="{classificationNameActive:topIndex==index}">{{item.name}}</view>
  13. <view class="classificationHx" v-if="topIndex==index"></view>
  14. </view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. <view style="height: 180rpx;"></view>
  19. <view class="paixuBox">
  20. <view class="paixuLine" @click="defaultpx" :class="{pxActive:defaultpxActive}">
  21. 默认排序
  22. </view>
  23. <view class="paixuLine" @click="xlPx(1)">
  24. <view :class="{pxActive:salessort}">销量</view>
  25. <view class="paixuLineTbBox">
  26. <view class="paixuLineTbtop" >
  27. <image v-if="salessorts" src="../../static/timg/icon_arrow_up_pre@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIcons"></image>
  28. <image v-else src="../../static/timg/icon_arrow_up_def@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIcons"></image>
  29. </view>
  30. <view class="paixuLineTbtop">
  31. <image v-if="salessortx" src="../../static/timg/icon_arrow_pre@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIconx"></image>
  32. <image v-else src="../../static/timg/icon_arrow_def@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIconx"></image>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="paixuLine" @click="jgpx(1)">
  37. <view :class="{pxActive:pricesort}">价格</view>
  38. <view class="paixuLineTbBox">
  39. <view class="paixuLineTbtop" >
  40. <image v-if="pricesorts" src="../../static/timg/icon_arrow_up_pre@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIcons"></image>
  41. <image v-else src="../../static/timg/icon_arrow_up_def@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIcons"></image>
  42. </view>
  43. <view class="paixuLineTbtop">
  44. <image v-if="pricesortx" src="../../static/timg/icon_arrow_pre@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIconx"></image>
  45. <image v-else src="../../static/timg/icon_arrow_def@2x.png" mode="" class="paixuLineTbtopIcon paixuLineTbtopIconx"></image>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <scroll-view scroll-Y="true" class="scroll-Y goodsSw" >
  51. <view class="goodsBox">
  52. <view class="hotGoodsLine" v-for="(item,index) in list" @click="goDetail(item)">
  53. <view>
  54. <image :src="item.url" v-if="item.url" mode="" @error="defImg()" class="hotGoodsLineImg"></image>
  55. <image v-else src="../../static/timg/noimg.png" mode="" class="hotGoodsLineImg"></image>
  56. </view>
  57. <view class="hotGoodsLineRIght">
  58. <view class="goodsName">{{item.name}}</view>
  59. <view class="Sold" >
  60. <view v-if="item.showLabel&&item.showLabel.indexOf('3')!=-1">
  61. 已售 {{item.saleQty}}
  62. </view>
  63. </view>
  64. <view class="goodsPrice">
  65. <view class="goodsPrice1">{{item.saleLabel}}</view>
  66. <view class="goodsPrice2">¥</view>
  67. <view class="goodsPrice3">{{item.salePrice?item.salePrice:item.scribingPrice}}</view>
  68. <view class="goodsPrice4" v-if="item.showLabel&&item.scribingPrice">
  69. <span v-if="item.showLabel.indexOf('1')!=-1">¥{{item.scribingPrice}}</span>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <nodata v-if="list.length==0"></nodata>
  75. </view>
  76. </scroll-view>
  77. <!-- 手机号授权 -->
  78. <view class="authorizBox" v-if="authorizShow" @click="authorizShow=false">
  79. <view class="authorizCont" @click.stop="">
  80. <view class="authorizName">{{wxOpenData.miniAppName}}</view>
  81. <view class="authorizMs">您好,欢迎访问本店,授权手机号登录能获取我们最新的促销活动哦~</view>
  82. <button class="authorizContbutton" type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权</button>
  83. </view>
  84. <view style="text-align: center;padding-top: 56rpx;">
  85. <image src="../../static/timg/icon_guanbi@2x.png" mode="" class="authorizCloseImg"></image>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import nodata from '../../components/nodata/nodata.vue'
  92. export default {
  93. components: {
  94. nodata
  95. },
  96. data() {
  97. return {
  98. userInfo:'',
  99. salessort:false,
  100. salessorts:false,
  101. salessortx:false,
  102. pricesort:false,
  103. pricesorts:false,
  104. pricesortx:false,
  105. topIndex:0,
  106. categoryList:'',
  107. page:1,
  108. limit:10,
  109. name:'',
  110. categoryID:'',
  111. order:'',
  112. orderBy:'',
  113. list:[],
  114. defaultImg: require("../../static/timg/noimg.png"),
  115. defaultpxActive:false,
  116. authorizShow:false,
  117. code:'',
  118. wxOpenData:'',
  119. shopcategoryID:'',
  120. inputChShow:false,
  121. ext:'',
  122. }
  123. },
  124. watch:{
  125. name(val){
  126. console.log(val)
  127. if(val){
  128. this.inputChShow=true
  129. }
  130. },
  131. },
  132. onLoad(opt) {
  133. console.log(getApp().globalData.shopcategoryID)
  134. //this.userInfo = uni.getStorageSync("userInfo");
  135. this.shopcategoryID=getApp().globalData.shopcategoryID;
  136. if(this.shopcategoryID){
  137. this.categoryID=this.shopcategoryID
  138. }
  139. this.userInfo=this.$store.state.userInfo;
  140. this.wxOpenData=this.$store.state.wxOpenData;
  141. this.ext=this.$common.getExtStoreId();
  142. this.getcategoryList();
  143. this.getlistOpenGoodsPage();
  144. /* uni.getLocation({
  145. type: 'gcj02',
  146. success: function(res) {
  147. console.log(res)
  148. },
  149. fail(err) {
  150. console.log(err)
  151. }
  152. }); */
  153. },
  154. onShow() {
  155. var shopcategoryID = uni.getStorageSync("shopcategoryID")
  156. if(shopcategoryID){
  157. uni.removeStorageSync('shopcategoryID');
  158. if(this.categoryList){
  159. this.categoryList.forEach((item,index)=>{
  160. //console.log(item.id)
  161. if(item.id==shopcategoryID){
  162. this.topIndex=index
  163. }
  164. })
  165. this.categoryID=shopcategoryID;
  166. this.list=[];
  167. this.page=1;
  168. this.getlistOpenGoodsPage()
  169. }
  170. }
  171. },
  172. methods: {
  173. empty(){
  174. console.log("情况")
  175. this.name='';
  176. this.inputChShow=false;
  177. },
  178. decryptPhoneNumber: function(e) {
  179. console.log(e);
  180. this.code=e.detail.code
  181. this.wxPhoneLogin()
  182. this.authorizShow=false;
  183. },
  184. wxPhoneLogin(){
  185. var that=this;
  186. this.$http('miniApp2/sys/wxPhoneLogin', {
  187. appId:'wx33053a645546ec31',
  188. unionId:'EEADACCD-8A19-499D-8AD7-6975D2C93243',
  189. code:this.code,
  190. openId:this.wxOpenData.openid
  191. },'POST').then(res => {
  192. var data = res.data;
  193. if(data.loginInfo){
  194. this.userInfo=data.loginInfo.openUser;
  195. this.wxOpenData=data.loginInfo;
  196. this.$store.commit('mutationswxOpenData', data.loginInfo)
  197. this.$store.commit('mutationsuserInfo', this.userInfo)
  198. this.topIndex=1;
  199. this.list=[];
  200. this.page=1;
  201. this.getlistOpenGoodsPage()
  202. }
  203. })
  204. },
  205. xlPx(num){
  206. this.salessort=true;
  207. this.defaultpxActive=false;
  208. this.pricesort=false;
  209. this.pricesort=false;
  210. this.pricesorts=false;
  211. this.pricesortx=false;
  212. if(this.salessorts){
  213. num=2
  214. }
  215. if(num==1){
  216. this.salessorts=true;
  217. this.salessortx=false;
  218. this.orderBy='asc';
  219. }else{
  220. this.salessorts=false;
  221. this.salessortx=true;
  222. this.orderBy='desc';
  223. }
  224. this.order='SaleQty';
  225. this.list=[];
  226. this.page=1;
  227. this.getlistOpenGoodsPage()
  228. },
  229. jgpx(type){
  230. this.salessort=false;
  231. this.defaultpxActive=false;
  232. this.pricesort=true;
  233. this.salessort=false;
  234. this.salessorts=false;
  235. this.salessortx=false;
  236. if(this.pricesorts){
  237. type=2
  238. }
  239. if(type==1){
  240. this.pricesorts=true;
  241. this.pricesortx=false;
  242. this.orderBy='asc';
  243. }else{
  244. this.pricesorts=false;
  245. this.pricesortx=true;
  246. this.orderBy='desc';
  247. }
  248. this.order='SalePrice';
  249. this.list=[];
  250. this.page=1;
  251. this.getlistOpenGoodsPage()
  252. },
  253. defaultpx(){
  254. this.defaultpxActive=true;
  255. this.order='';
  256. this.orderBy='';
  257. this.salessort=false;
  258. this.salessorts=false;
  259. this.salessortx=false;
  260. this.pricesort=false;
  261. this.pricesorts=false;
  262. this.pricesortx=false;
  263. //this.topIndex=0;
  264. this.list=[];
  265. this.page=1;
  266. this.getlistOpenGoodsPage()
  267. },
  268. defImg(event){
  269. // console.log(event)
  270. /* let img = event.srcElement;
  271. img.src = this.defaultImg;
  272. img.onerror = null; //防止闪图 */
  273. },
  274. topClick(index,item){
  275. this.topIndex=index;
  276. this.list=[];
  277. this.page=1;
  278. this.categoryID=item.id;
  279. this.getlistOpenGoodsPage()
  280. },
  281. ssList(){
  282. this.topIndex=1;
  283. this.list=[];
  284. this.page=1;
  285. this.getlistOpenGoodsPage()
  286. },
  287. goDetail(item){
  288. // if(!this.userInfo){
  289. // this.authorizShow=true;
  290. // }else{
  291. // }
  292. uni.navigateTo({
  293. url:'goodsDetail?id='+item.id
  294. })
  295. },
  296. getcategoryList(){
  297. this.$http('openMall/categoryList', {
  298. unionId:this.ext.unionId
  299. },'GET').then(res => {
  300. this.categoryList=res.data;
  301. var obj={
  302. id:'',
  303. name:'全部'
  304. }
  305. this.categoryList.unshift(obj);
  306. if(this.shopcategoryID){
  307. //console.log(this.shopcategoryID)
  308. this.categoryList.forEach((item,index)=>{
  309. //console.log(item.id)
  310. if(item.id==this.shopcategoryID){
  311. this.topIndex=index
  312. }
  313. })
  314. }
  315. })
  316. },
  317. getlistOpenGoodsPage(){
  318. uni.showLoading({ title: '加载中'});
  319. this.$http('openMall/listOpenGoodsPage', {
  320. page:this.page,
  321. limit:this.limit,
  322. name:this.name,
  323. categoryID:this.categoryID,
  324. orderBy:this.order,
  325. order:this.orderBy,
  326. unionId:this.ext.unionId
  327. },'GET').then(res => {
  328. uni.hideLoading();
  329. var data=res.data.Items;
  330. this.list=this.list.concat(data)
  331. })
  332. }
  333. },
  334. onReachBottom(){
  335. this.page++;
  336. this.getlistOpenGoodsPage()
  337. //console.log("shanglas")
  338. },
  339. onPullDownRefresh(){
  340. this.list=[];
  341. this.page=1;
  342. this.getlistOpenGoodsPage();
  343. setTimeout(() => {
  344. uni.stopPullDownRefresh(); // 关闭下拉刷新
  345. }, 2000);
  346. }
  347. }
  348. </script>
  349. <style scoped lang="less">
  350. .topbox{
  351. position: fixed;
  352. width: 750rpx;
  353. top: -1rpx;
  354. left: 0;
  355. z-index: 11;
  356. }
  357. .inputCh{
  358. width:40rpx;
  359. height: 40rpx;
  360. position: absolute;
  361. right: 40rpx;
  362. top: 40rpx;
  363. z-index: 11;
  364. }
  365. .pxActive{
  366. color: #FF0000 !important;
  367. }
  368. .paixuLineTbtopIcon{
  369. width: 16rpx;
  370. height: 8rpx;
  371. display: block;
  372. padding-left: 10rpx;
  373. }
  374. .paixuLineTbtopIconx{
  375. padding-bottom:24rpx;
  376. }
  377. .paixuLineTbtopIcons{
  378. padding-top: 8rpx;
  379. }
  380. .paixuLineTbBox{
  381. display: flex;
  382. flex-direction: column;
  383. justify-content: space-between;
  384. }
  385. .box{
  386. background: #F4F5F7;
  387. min-height: 100vh;
  388. }
  389. .sstopInput{
  390. width: 626rpx;
  391. height: 72rpx;
  392. background: #F4F5F7;
  393. border-radius: 36rpx;
  394. line-height: 72rpx;
  395. font-size: 28rpx;
  396. padding-left: 76rpx;
  397. }
  398. .sstop{
  399. position: relative;
  400. padding-top: 24rpx;
  401. padding-left: 24rpx;
  402. background: #ffffff;
  403. }
  404. .sstopimg{
  405. width: 40rpx;
  406. height: 40rpx;
  407. position: absolute;
  408. left: 44rpx;
  409. top: 40rpx;
  410. }
  411. .scroll-Y{
  412. background: #ffffff;
  413. width: 750rpx;
  414. }
  415. .goodsBox{
  416. min-height: calc(100vh - 280rpx);
  417. }
  418. .classificationBox{
  419. display: flex;
  420. padding-bottom: 12rpx;
  421. }
  422. .classificationName{
  423. white-space: nowrap;
  424. font-size: 28rpx;
  425. color: #3C3C3C;
  426. line-height: 40rpx;
  427. padding:24rpx 24rpx 8rpx 24rpx;
  428. font-weight: 400;
  429. }
  430. .classificationNameActive{
  431. font-weight: 500 !important;
  432. color: #FF0000 ;
  433. }
  434. .classificationHx{
  435. width: 40rpx;
  436. height: 4rpx;
  437. background: #FF0000;
  438. margin: 0 auto;
  439. }
  440. .paixuBox{
  441. width: 750rpx;
  442. height: 72rpx;
  443. background: #FFFFFF;
  444. margin-top: 20rpx;
  445. display: flex;
  446. justify-content: space-around;
  447. border-bottom: 1px solid #EEEEEE;
  448. }
  449. .paixuLine{
  450. line-height: 37rpx;font-size: 26rpx;color: #666666;padding-top: 18rpx;
  451. display: flex;
  452. }
  453. .hotGoodsLine{
  454. margin-top: 30rpx;
  455. padding:0rpx 20rpx;
  456. background: #FFFFFF;
  457. border-radius: 16rpx;
  458. display: flex;
  459. }
  460. .hotGoodsLineImg{
  461. width: 208rpx;
  462. height: 194rpx;
  463. border-radius: 16rpx;
  464. border: 1px solid #EEEEEE;
  465. display: block;
  466. }
  467. .goodsName{
  468. font-size: 28rpx;
  469. font-family: PingFangSC-Regular, PingFang SC;
  470. font-weight: 400;
  471. color: #333333;
  472. line-height: 40rpx;
  473. text-overflow: -o-ellipsis-lastline;
  474. overflow: hidden;
  475. text-overflow: ellipsis;
  476. display: -webkit-box;
  477. -webkit-line-clamp: 2;
  478. line-clamp: 2;
  479. -webkit-box-orient: vertical;
  480. }
  481. .hotGoodsLineRIght{
  482. padding-left: 24rpx;
  483. }
  484. .goodsPrice{
  485. display: flex;
  486. padding-top: 10rpx;
  487. }
  488. .goodsPrice1{
  489. font-size: 24rpx;
  490. font-weight: 400;
  491. color: #FF0000;
  492. padding-top: 8rpx;
  493. }
  494. .goodsPrice2{
  495. font-size: 22rpx;
  496. font-weight: 400;
  497. color: #FF0000;
  498. padding-top: 10rpx;
  499. }
  500. .goodsPrice3{
  501. font-size: 32rpx;
  502. font-weight: 500;
  503. color: #FF0000;
  504. }
  505. .goodsPrice4{
  506. font-size: 24rpx;
  507. font-weight: 400;
  508. color: #999999;
  509. padding-top: 8rpx;
  510. text-decoration:line-through;
  511. padding-left: 10rpx;
  512. }
  513. .Sold{
  514. font-weight: 400;
  515. color: #999999;
  516. font-size: 24rpx;
  517. padding-top: 8rpx;
  518. line-height: 30rpx;
  519. height: 30rpx;
  520. }
  521. .authorizBox{
  522. width: 100vw;
  523. height: 100vh;
  524. background: rgba(0, 0, 0, 0.5);
  525. position: fixed;
  526. top: 0;
  527. left: 0;
  528. }
  529. .authorizCont{
  530. margin-top: 30vh;
  531. width: 564rpx;
  532. height: 408rpx;
  533. background: #FFFFFF;
  534. border-radius: 24rpx;
  535. margin-left: 93rpx;
  536. position: relative;
  537. }
  538. .authorizCloseImg{
  539. width: 62rpx;
  540. height: 62rpx;
  541. }
  542. .sqLogoBox{
  543. width: 180rpx;
  544. height: 180rpx;
  545. background: #FFFFFF;
  546. border-radius: 90rpx;
  547. text-align: center;
  548. position: absolute;
  549. top: -50rpx;
  550. left: 192rpx;
  551. }
  552. .authorizName{
  553. color: #333333;
  554. line-height: 42rpx;
  555. font-size: 30rpx;
  556. text-align: center;
  557. padding-top: 58rpx;
  558. }
  559. .authorizMs{
  560. color: #999999;
  561. line-height: 36rpx;
  562. font-size: 26rpx;
  563. width: 452rpx;
  564. padding-top: 24rpx;
  565. text-align: center;
  566. margin-left: 56rpx;
  567. }
  568. .authorizContbutton{
  569. width: 422rpx;
  570. height: 88rpx;
  571. background: #D53533;
  572. border-radius: 44rpx;
  573. line-height: 88rpx;
  574. text-align: center;
  575. font-size:30rpx;
  576. color: #FFFFFF;
  577. margin-top: 62rpx;
  578. margin-left:71rpx;
  579. }
  580. </style>