shop.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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" mode="" @error="defImg()" class="hotGoodsLineImg"></image>
  52. </view>
  53. <view class="hotGoodsLineRIght">
  54. <view class="goodsName">{{item.name}}</view>
  55. <view class="Sold">已售 {{item.saleQty}}</view>
  56. <view class="goodsPrice">
  57. <view class="goodsPrice1">店庆价</view>
  58. <view class="goodsPrice2">¥</view>
  59. <view class="goodsPrice3">{{item.scribingPrice?item.scribingPrice:item.salePrice}}</view>
  60. <view class="goodsPrice4" v-if="item.scribingPrice">¥{{item.salePrice}}</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. components: {
  72. },
  73. data() {
  74. return {
  75. userInfo:'',
  76. salessort:false,
  77. salessorts:false,
  78. salessortx:false,
  79. pricesort:false,
  80. pricesorts:false,
  81. pricesortx:false,
  82. topIndex:0,
  83. categoryList:'',
  84. page:1,
  85. limit:10,
  86. name:'',
  87. categoryID:'',
  88. order:'',
  89. orderBy:'',
  90. list:[],
  91. defaultImg: require("../../static/timg/noimg.png"),
  92. defaultpxActive:true,
  93. }
  94. },
  95. onLoad() {
  96. this.userInfo = uni.getStorageSync("userInfo");
  97. //this.getOrderTimes()
  98. this.getcategoryList();
  99. this.getlistOpenGoodsPage();
  100. uni.getLocation({
  101. type: 'gcj02',
  102. success: function(res) {
  103. console.log(res)
  104. },
  105. fail(err) {
  106. console.log(err)
  107. }
  108. });
  109. },
  110. methods: {
  111. xlPx(num){
  112. this.salessort=true;
  113. this.defaultpxActive=false;
  114. this.pricesort=false;
  115. this.pricesort=false;
  116. this.pricesorts=false;
  117. this.pricesortx=false;
  118. if(num==1){
  119. this.salessorts=true;
  120. this.salessortx=false;
  121. this.orderBy='asc';
  122. }else{
  123. this.salessorts=false;
  124. this.salessortx=true;
  125. this.orderBy='desc';
  126. }
  127. this.order='SaleQty';
  128. this.list=[];
  129. this.page=1;
  130. this.getlistOpenGoodsPage()
  131. },
  132. jgpx(type){
  133. this.salessort=false;
  134. this.defaultpxActive=false;
  135. this.pricesort=true;
  136. this.salessort=false;
  137. this.salessorts=false;
  138. this.salessortx=false;
  139. if(type==1){
  140. this.pricesorts=true;
  141. this.pricesortx=false;
  142. this.orderBy='asc';
  143. }else{
  144. this.pricesorts=false;
  145. this.pricesortx=true;
  146. this.orderBy='desc';
  147. }
  148. this.order='SalePrice';
  149. this.list=[];
  150. this.page=1;
  151. this.getlistOpenGoodsPage()
  152. },
  153. defaultpx(){
  154. this.order='';
  155. this.orderBy='';
  156. this.salessort=false;
  157. this.salessorts=false;
  158. this.salessortx=false;
  159. this.pricesort=false;
  160. this.pricesorts=false;
  161. this.pricesortx=false;
  162. //this.topIndex=0;
  163. this.list=[];
  164. this.page=1;
  165. this.getlistOpenGoodsPage()
  166. },
  167. defImg(event){
  168. // console.log(event)
  169. /* let img = event.srcElement;
  170. img.src = this.defaultImg;
  171. img.onerror = null; //防止闪图 */
  172. },
  173. topClick(index,item){
  174. this.topIndex=index;
  175. this.list=[];
  176. this.page=1;
  177. this.categoryID=item.id;
  178. this.getlistOpenGoodsPage()
  179. },
  180. ssList(){
  181. this.topIndex=1;
  182. this.list=[];
  183. this.page=1;
  184. this.getlistOpenGoodsPage()
  185. },
  186. goDetail(item){
  187. uni.navigateTo({
  188. url:'goodsDetail?id='+item.id
  189. })
  190. },
  191. getcategoryList(){
  192. this.$http('openMall/categoryList', {
  193. },'GET').then(res => {
  194. this.categoryList=res.data;
  195. var obj={
  196. id:'',
  197. name:'全部'
  198. }
  199. this.categoryList.unshift(obj)
  200. })
  201. },
  202. getlistOpenGoodsPage(){
  203. uni.showLoading({ title: '加载中'});
  204. this.$http('openMall/listOpenGoodsPage', {
  205. page:this.page,
  206. limit:this.limit,
  207. name:this.name,
  208. categoryID:this.categoryID,
  209. order:this.order,
  210. orderBy:this.orderBy,
  211. },'GET').then(res => {
  212. uni.hideLoading();
  213. var data=res.data.Items;
  214. this.list=this.list.concat(data)
  215. })
  216. }
  217. },
  218. onReachBottom(){
  219. this.page++;
  220. this.getlistOpenGoodsPage()
  221. //console.log("shanglas")
  222. }
  223. }
  224. </script>
  225. <style scoped lang="less">
  226. .pxActive{
  227. color: #FF0000 !important;
  228. }
  229. .paixuLineTbtopIcon{
  230. width: 16rpx;
  231. height: 8rpx;
  232. display: block;
  233. padding-left: 10rpx;
  234. }
  235. .paixuLineTbtopIconx{
  236. padding-bottom:20rpx;
  237. }
  238. .paixuLineTbtopIcons{
  239. padding-top: 6rpx;
  240. }
  241. .paixuLineTbBox{
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: space-between;
  245. }
  246. .box{
  247. background: #F4F5F7;
  248. min-height: 100vh;
  249. }
  250. .sstopInput{
  251. width: 626rpx;
  252. height: 72rpx;
  253. background: #F4F5F7;
  254. border-radius: 36rpx;
  255. line-height: 72rpx;
  256. font-size: 28rpx;
  257. padding-left: 76rpx;
  258. }
  259. .sstop{
  260. position: relative;
  261. padding-top: 24rpx;
  262. padding-left: 24rpx;
  263. background: #ffffff;
  264. }
  265. .sstopimg{
  266. width: 40rpx;
  267. height: 40rpx;
  268. position: absolute;
  269. left: 44rpx;
  270. top: 40rpx;
  271. }
  272. .scroll-Y{
  273. background: #ffffff;
  274. width: 750rpx;
  275. }
  276. .classificationBox{
  277. display: flex;
  278. padding-bottom: 12rpx;
  279. }
  280. .classificationName{
  281. white-space: nowrap;
  282. font-size: 28rpx;
  283. color: #3C3C3C;
  284. line-height: 40rpx;
  285. padding:24rpx 24rpx 8rpx 24rpx;
  286. }
  287. .classificationHx{
  288. width: 40rpx;
  289. height: 4rpx;
  290. background: #FF0000;
  291. margin: 0 auto;
  292. }
  293. .paixuBox{
  294. width: 750rpx;
  295. height: 72rpx;
  296. background: #FFFFFF;
  297. margin-top: 20rpx;
  298. display: flex;
  299. justify-content: space-around;
  300. }
  301. .paixuLine{
  302. line-height: 37rpx;font-size: 26rpx;color: #666666;padding-top: 18rpx;
  303. display: flex;
  304. }
  305. .hotGoodsLine{
  306. margin-top: 20rpx;
  307. padding: 20rpx;
  308. background: #FFFFFF;
  309. border-radius: 16rpx;
  310. display: flex;
  311. }
  312. .hotGoodsLineImg{
  313. width: 208rpx;
  314. height: 194rpx;
  315. border-radius: 16rpx;
  316. border: 1px solid #EEEEEE;
  317. }
  318. .goodsName{
  319. font-size: 28rpx;
  320. font-family: PingFangSC-Regular, PingFang SC;
  321. font-weight: 400;
  322. color: #333333;
  323. line-height: 40rpx;
  324. text-overflow: -o-ellipsis-lastline;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. display: -webkit-box;
  328. -webkit-line-clamp: 2;
  329. line-clamp: 2;
  330. -webkit-box-orient: vertical;
  331. }
  332. .hotGoodsLineRIght{
  333. padding-left: 24rpx;
  334. }
  335. .goodsPrice{
  336. display: flex;
  337. padding-top: 10rpx;
  338. }
  339. .goodsPrice1{
  340. font-size: 24rpx;
  341. font-weight: 400;
  342. color: #FF0000;
  343. padding-top: 8rpx;
  344. }
  345. .goodsPrice2{
  346. font-size: 22rpx;
  347. font-weight: 400;
  348. color: #FF0000;
  349. padding-top: 8rpx;
  350. }
  351. .goodsPrice3{
  352. font-size: 32rpx;
  353. font-weight: 400;
  354. color: #FF0000;
  355. }
  356. .goodsPrice4{
  357. font-size: 24rpx;
  358. font-weight: 400;
  359. color: #999999;
  360. padding-top: 8rpx;
  361. }
  362. .Sold{
  363. font-weight: 400;
  364. color: #999999;
  365. font-size: 24rpx;
  366. padding-top: 8rpx;
  367. }
  368. </style>