index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. }else{
  191. that.$refs.toast.show({model:'error',label:res.data.msg})
  192. }
  193. })
  194. // uni.navigateTo({
  195. // url: "/pages/gouwuche/index",
  196. // })
  197. // console.log(data)
  198. // this.gouwuche.push(data)
  199. },
  200. goindex(){
  201. uni.navigateBack();
  202. },
  203. change(e){
  204. console.log(e);
  205. if(e.title=='价格'){
  206. if(e.shang){
  207. this.jia=1
  208. }else{
  209. this.jia=2
  210. }
  211. console.log(e.shang);
  212. }else{
  213. if(e.shang){
  214. this.num=1
  215. }else{
  216. this.num=2
  217. }
  218. }
  219. this.sosoFun()
  220. },
  221. },
  222. }
  223. </script>
  224. <style lang="scss">
  225. /deep/ .tm-menubars .body{background-color: #1b1b1b !important;}
  226. /deep/ .zhuti{padding: 10px 10px;}
  227. /deep/ .kuang{margin:0 !important;padding: 0px !important;}
  228. /deep/ .icon-search{
  229. font-size: 23px !important;
  230. color: #8E8E93 !important;
  231. }
  232. /deep/ .tm-search{
  233. width: 66%;
  234. background-color: #414141 !important;
  235. border-radius: 10px;
  236. }
  237. /deep/ .tm-search .grey-darken-5{
  238. background-color: #414141 !important;
  239. }
  240. .qingchu{background: #303440;padding:5px 15px;border-radius: 20px;width: 62px;}
  241. /deep/ .liebiao .grey-darken-4.bk{background-color: #0D0D0D !important;}
  242. /deep/ .liebiao .py-24{padding-top: 15px;padding-bottom: 15px;}
  243. /deep/ .tm-grouplist{margin:0 10px !important;}
  244. .quxiao{color: #707070;line-height: 47px;}
  245. /deep/ .tm--badges--cm{border: 1px solid #303440 !important;
  246. background-color: #303440 !important;right: -7px !important;top: 6px !important;}
  247. /deep/ .tm--badges{display: inherit !important;}
  248. .qingchu{background: #303440;padding:5px 15px;border-radius: 20px;width: 62px;}
  249. /deep/ .liebiao .grey-darken-4.bk{background-color: #0D0D0D !important;}
  250. /deep/ .liebiao .py-24{padding-top: 15px;padding-bottom: 15px;}
  251. /deep/ .tm-grouplist{margin:0 10px !important;}
  252. /deep/ .qiehuan2 .tm-tabs-con-item-border{display: none;}
  253. /deep/ .qiehuan1 .text-primary{color: white !important;}
  254. /deep/ .qiehuan2 .tm-tabs-con-item-text{
  255. font-size: 14px;
  256. background: none !important;
  257. height: 28px;
  258. vertical-align: middle;
  259. line-height: 28px;
  260. border-radius: 20px;
  261. padding-left: 14px;
  262. padding-right: 14px;
  263. margin-top: 17%;
  264. }
  265. /deep/ .qiehuan2 .text-weight-b{
  266. font-size: 14px;
  267. background: #303440 !important;
  268. height: 28px;
  269. vertical-align: middle;
  270. line-height: 28px;
  271. border-radius: 20px;
  272. padding-left: 14px;
  273. padding-right: 14px;
  274. margin-top: 17%;
  275. color: white !important;
  276. }
  277. .dingwei{width: 21%;margin-top:3%;}
  278. .shuruk{width: 77%;}
  279. .sousuo{width:94%;margin:0 auto;}
  280. .quxiao{color: #707070;line-height: 47px;}
  281. .contone{width: 48%;}
  282. .logo{width: 100%;}
  283. .remenzan{width: 18px !important;margin-top: 10px;}
  284. .more{text-align: center;}
  285. .more image{margin-right: 10px;vertical-align: middle;width: 30px;}
  286. </style>