index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }" :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  3. <tm-menubars title="" :shadow="0" :showback="false"></tm-menubars>
  4. <view class="C1b1b1b pb-10">
  5. <view class="sousuo">
  6. <tm-pickersCity class="dingwei fl" btn-color="bg-gradient-blue-accent" @confirm="okCity" :default-value="addr">
  7. <view>
  8. <text class="text-size-n">{{addr[1]}}</text>
  9. <tm-icons :size="24" color="white" name="icon-angle-down"></tm-icons>
  10. </view>
  11. </tm-pickersCity>
  12. <view>
  13. <tm-search @confirm="sosoFun" class="fl" v-model="soso" color="white" confirm-text=""></tm-search>
  14. <text class="quxiao fr" @click="goindex()">取消</text>
  15. </view>
  16. <view style="clear: both;"></view>
  17. <view v-if="sosotype==1">
  18. <text class="text-size-m fl mt-30">搜索记录</text>
  19. <view class="fr mt-30 qingchu" @click="qingkong" v-if="libiaoList.length !=0">
  20. <text class="text-size-s fl">清空记录</text>
  21. <tm-badges :offset="[0,-5]" icon="icon-times"></tm-badges>
  22. </view>
  23. </view>
  24. <view v-if="sosotype==2">
  25. <tm-dropDownMenu @change="change" :type="typeclick" un-color="white" :list="list2"></tm-dropDownMenu>
  26. </view>
  27. <view style="clear: both;"></view>
  28. </view>
  29. </view>
  30. <!-- 列表 -->
  31. <tm-grouplist class="liebiao mt-40" v-if="sosotype==1 && libiaoList.length !=0">
  32. <tm-listitem v-for="item in libiaoList" @click="sousuo(item.name)" :title="item.name" left-icon="" show-left-icon :show-right-icon="false">
  33. </tm-listitem>
  34. </tm-grouplist>
  35. <tm-empty v-if="sosotype==1 && libiaoList==undefined" label="暂无数据" color="white" icon="icon-paperplane-fill"></tm-empty>
  36. <div class="zhuti" v-if="sosotype==2">
  37. <tm-sheet class="kuang" style="padding-bottom: 30px !important;" v-if="listdata.length!=0">
  38. <view style="width: 94%;margin:0 auto;" class="remen">
  39. <view v-for="(item,index) in listdata" class="round-5 contone black mt-20" :class="index%2==0?'fl':'fr'" @click="goDetail(item.category_id)">
  40. <image class="logo" :src="item.image" mode="widthFix"></image>
  41. <view class="pa-15 text-size-s">
  42. <view class="text-overflow-2">
  43. <text class="text-size-lg">{{item.goods_name}}</text>
  44. <view class="text-gray mt-6">销量:{{item.stock_num}}</view>
  45. </view>
  46. <view class="mt-2 flex-between flex-center">
  47. <view class="touxiang mt-30">
  48. <text class="text-white text-size-m text-weight-b">{{item.sale_price}}</text>
  49. </view>
  50. <view >
  51. <image @click.stop="jiarufuFun(item)" class="remenzan" src="/static/img/86.png" mode="widthFix"></image>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view style="clear: both;"></view>
  57. <view style="clear: both;" class="more ma-40 pt-40" @click="gengmore()" v-if="listdata.length<total">
  58. <image src="/static/img/30.png" mode="widthFix"></image>
  59. <text class="text-size-s">下拉加载更多~</text>
  60. </view>
  61. </view>
  62. </tm-sheet>
  63. <view style="height:60px"></view>
  64. </div>
  65. <!-- 弹出层消息 -->
  66. <tm-message ref="toast"></tm-message>
  67. </view>
  68. </template>
  69. <script>
  70. import{myRequest} from '@/api/request.js'
  71. export default {
  72. data() {
  73. return {
  74. libiaoList:[],
  75. activeIndex:0,
  76. soso:'',
  77. addr:['江西省','南昌市','西湖区'],
  78. value:'',
  79. list2: [{
  80. title: '最近上新',
  81. shang:true
  82. }, {
  83. title: '价格',
  84. shang:true
  85. },{
  86. title: '销量',
  87. shang:true
  88. }],
  89. typeclick:1,
  90. listdata:[],
  91. sosotype:1,
  92. page:1,
  93. pagesize:8,
  94. total:0,
  95. jia:1,
  96. num:1,
  97. };
  98. },
  99. onLoad() {
  100. },
  101. created() {
  102. this.sys = uni.getSystemInfoSync();
  103. this.getlishi()
  104. },
  105. methods: {
  106. goDetail(cartId){
  107. uni.navigateTo({
  108. url:'/pages/shopdetail/index?cartId='+cartId
  109. })
  110. },
  111. getlishi(){
  112. var that=this;
  113. myRequest({
  114. url: "/api/ShopGoods/shopSearchList",
  115. method:'get',
  116. data:{}
  117. }).then(res => {
  118. if (res.data.code == 200) {
  119. that.libiaoList=res.data.data;
  120. }else{}
  121. })
  122. },
  123. qingkong(){
  124. var that=this;
  125. myRequest({
  126. url: "/api/ShopGoods/deleteShopSearch",
  127. method:'get',
  128. data:{}
  129. }).then(res => {
  130. if (res.data.code == 200) {
  131. that.getlishi();
  132. that.$refs.toast.show({model:'success',label:res.data.msg})
  133. }else{
  134. }
  135. })
  136. },
  137. sousuo(name){
  138. console.log(name,'nam');
  139. this.soso=name;
  140. this.sosoFun();
  141. },
  142. sosoFun(){
  143. let that=this;
  144. myRequest({
  145. url:'/api/ShopGoods/shopGoodsSearch',
  146. method:'post',
  147. data:{search:that.soso,page:that.page,pagesize:that.pagesize,sale_price:that.jia,sale_num:that.num}
  148. }).then(res=>{
  149. if(res.data.code==200){
  150. that.listdata=[];
  151. if(res.data.data.length!=0){
  152. that.total=res.data.data.total;
  153. if(res.data.data.data.length>0){
  154. that.listdata=res.data.data.data;
  155. }else{
  156. that.listdata=[];
  157. }
  158. }else{
  159. that.listdata=[];
  160. }
  161. }else{
  162. that.$refs.toast.show({
  163. model: 'error',
  164. label: res.data.msg
  165. })
  166. }
  167. })
  168. this.sosotype=2
  169. },
  170. gengmore(){
  171. // this.randouh()
  172. },
  173. jiarufuFun(data){
  174. var that=this;
  175. console.log(data)
  176. // if(data.type==2){
  177. myRequest({
  178. url: "/api/ShopCart/addShopCart",
  179. method:'post',
  180. data:{
  181. goods_id:data.id,
  182. goods_name:data.goods_name,
  183. goods_image:data.image,
  184. goods_price:data.sale_price,
  185. goods_num:1
  186. }
  187. }).then(res => {
  188. if (res.data.code == 200) {
  189. that.$refs.toast.show({model:'success',label:res.data.msg})
  190. // that.getGwc()
  191. }else{
  192. that.$refs.toast.show({model:'error',label:res.data.msg})
  193. }
  194. })
  195. // }else{
  196. // uni.navigateTo({
  197. // url: "/pages/shopdetail/index",
  198. // })
  199. // }
  200. // uni.navigateTo({
  201. // url: "/pages/gouwuche/index",
  202. // })
  203. // console.log(data)
  204. // this.gouwuche.push(data)
  205. },
  206. goindex(){
  207. uni.navigateBack();
  208. },
  209. change(e){
  210. console.log(e);
  211. if(e.title=='价格'){
  212. if(e.shang){
  213. this.jia=1
  214. }else{
  215. this.jia=2
  216. }
  217. console.log(e.shang);
  218. }else{
  219. if(e.shang){
  220. this.num=1
  221. }else{
  222. this.num=2
  223. }
  224. }
  225. this.sosoFun()
  226. },
  227. },
  228. }
  229. </script>
  230. <style lang="scss">
  231. /deep/ .tm-menubars .body{background-color: #1b1b1b !important;}
  232. /deep/ .zhuti{padding: 10px 10px;}
  233. /deep/ .kuang{margin:0 !important;padding: 0px !important;}
  234. /deep/ .icon-search{
  235. font-size: 23px !important;
  236. color: #8E8E93 !important;
  237. }
  238. /deep/ .tm-search{
  239. width: 66%;
  240. background-color: #414141 !important;
  241. border-radius: 10px;
  242. }
  243. /deep/ .tm-search .grey-darken-5{
  244. background-color: #414141 !important;
  245. }
  246. .qingchu{background: #303440;padding:5px 15px;border-radius: 20px;width: 62px;}
  247. /deep/ .liebiao .grey-darken-4.bk{background-color: #0D0D0D !important;}
  248. /deep/ .liebiao .py-24{padding-top: 15px;padding-bottom: 15px;}
  249. /deep/ .tm-grouplist{margin:0 10px !important;}
  250. .quxiao{color: #707070;line-height: 47px;}
  251. /deep/ .tm--badges--cm{border: 1px solid #303440 !important;
  252. background-color: #303440 !important;right: -7px !important;top: 6px !important;}
  253. /deep/ .tm--badges{display: inherit !important;}
  254. .qingchu{background: #303440;padding:5px 15px;border-radius: 20px;width: 62px;}
  255. /deep/ .liebiao .grey-darken-4.bk{background-color: #0D0D0D !important;}
  256. /deep/ .liebiao .py-24{padding-top: 15px;padding-bottom: 15px;}
  257. /deep/ .tm-grouplist{margin:0 10px !important;}
  258. /deep/ .qiehuan2 .tm-tabs-con-item-border{display: none;}
  259. /deep/ .qiehuan1 .text-primary{color: white !important;}
  260. /deep/ .qiehuan2 .tm-tabs-con-item-text{
  261. font-size: 14px;
  262. background: none !important;
  263. height: 28px;
  264. vertical-align: middle;
  265. line-height: 28px;
  266. border-radius: 20px;
  267. padding-left: 14px;
  268. padding-right: 14px;
  269. margin-top: 17%;
  270. }
  271. /deep/ .qiehuan2 .text-weight-b{
  272. font-size: 14px;
  273. background: #303440 !important;
  274. height: 28px;
  275. vertical-align: middle;
  276. line-height: 28px;
  277. border-radius: 20px;
  278. padding-left: 14px;
  279. padding-right: 14px;
  280. margin-top: 17%;
  281. color: white !important;
  282. }
  283. .dingwei{width: 21%;margin-top:3%;}
  284. .shuruk{width: 77%;}
  285. .sousuo{width:94%;margin:0 auto;}
  286. .quxiao{color: #707070;line-height: 47px;}
  287. .contone{width: 48%;}
  288. .logo{width: 100%;}
  289. .remenzan{width: 18px !important;margin-top: 10px;}
  290. .more{text-align: center;}
  291. .more image{margin-right: 10px;vertical-align: middle;width: 30px;}
  292. </style>