index.vue 8.8 KB

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