shop.vue 12 KB

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