index.vue 8.5 KB

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