index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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-40">
  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. <tm-search v-model="soso" class="fr shuruk" color="white" confirm-text="" @click="sosoFun"></tm-search>
  14. </view>
  15. <view style="clear: both;"></view>
  16. </view>
  17. <view class="lunbo">
  18. <tm-swiper :previmage="false" @change="lunboFun" :list="list" :height="400" :current="current"></tm-swiper>
  19. <tm-translate class="anniu1 fl" :auto="true" ref="a_1" :duration="80" animation-name="zoomIn">
  20. <image v-if="current!=0" @click="xia()" class="qiehuan" src="/static/img/68.png" mode="widthFix">
  21. </image>
  22. </tm-translate>
  23. <tm-translate class="anniu2 fr" :auto="true" ref="a_5" :duration="80" animation-name="zoomIn">
  24. <image v-if="current<(list.length-1)" @click="shang()" class="qiehuan" src="/static/img/67.png"
  25. mode="widthFix"></image>
  26. </tm-translate>
  27. </view>
  28. <view class="zhuti">
  29. <tm-sheet :shadow="24" class="jiaoxi">
  30. <tm-grid @change="zhonglei" class="mt-20 mb-20" :grid="5" :list="list3" :icon-size="120"
  31. font-color="white"></tm-grid>
  32. </tm-sheet>
  33. <!-- <tm-sheet :shadow="24" class="jiaoxi xiao">
  34. <view class="yifu1 fl">
  35. <image src="/static/img/78.png" mode="widthFix"></image>
  36. </view>
  37. <view class="yifu2 fr">
  38. <image class="yifu21" src="/static/img/77.png" mode="widthFix"></image>
  39. <view>
  40. <image style="width:50%;" src="/static/img/75.png" mode="widthFix"></image>
  41. <image style="width:50%;" class="yifu21" src="/static/img/76.png" mode="widthFix"></image>
  42. </view>
  43. </view>
  44. <view style="clear: both;"></view>
  45. </tm-sheet> -->
  46. <tm-sheet :shadow="24" class="jiaoxi xiao">
  47. <tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list2" range-key="title"
  48. @change="changeTab(activeIndex)"></tm-tabs>
  49. </tm-sheet>
  50. <tm-sheet :shadow="24" class="jiaoxi xiao" style="height:160px;">
  51. <tm-dragGrid :list="list1" :col="3" disabled="false" class="mt-40 mb-40 remen" :icon-size="160"
  52. v-if="list1.length!=0">
  53. <template v-slot:default="{item}">
  54. <view class="flex-center flex-col" @click="tiaozhuan()">
  55. <tm-icons :size="160" :name="item.icon" :color="item.color"></tm-icons>
  56. <text class="text-size-m text-white pt-10">{{item.text}}</text>
  57. <text class="text-size-m text-white pt-10">{{item.jie}}</text>
  58. </view>
  59. </template>
  60. </tm-dragGrid>
  61. </tm-sheet>
  62. </view>
  63. <view class="guanggao" @click="xiangqing">
  64. <image style="width:100%;" src="/static/img/82.png" mode="widthFix"></image>
  65. <view class="wenzi">
  66. <view class="mt-10">额外打九折</view>
  67. <view>高达75%的折扣!</view>
  68. </view>
  69. </view>
  70. <view style="height:160px;" class="mt-40 jiage pt-40">
  71. <tm-dragGrid :list="list4" :col="3" disabled="false" class="remen" :icon-size="160" v-if="list4.length!=0">
  72. <template v-slot:default="{item}">
  73. <view class="flex-center flex-col" @click.stop="goXiangQing(item)">
  74. <tm-icons :size="200" :name="item.icon" :color="item.color"></tm-icons>
  75. <text class="text-size-m text-white pt-10">{{item.text}}</text>
  76. <text class="text-size-m text-white pt-10">{{item.jie}}</text>
  77. </view>
  78. </template>
  79. </tm-dragGrid>
  80. </view>
  81. <tm-sheet :shadow="24" class="jiaoxi xiao">
  82. <tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list5" range-key="title"></tm-tabs>
  83. </tm-sheet>
  84. <!-- 单品 -->
  85. <view class="zhuti shangpin">
  86. <tm-sheet :padding="[0, 0]" class="jiaoxi xiao">
  87. <tm-cartCellListFood v-on:jiaruFun="jiarufuFun" v-on:goXiangQing="goXiangQing(item)"
  88. v-for="item in test" :typeclick="typeclick" :mdata="item" :cart-num.sync="item.buy">
  89. </tm-cartCellListFood>
  90. <view class="" v-if="isBottom"
  91. style="width: 100%;display: flex;justify-content: center;align-items: center;">
  92. 没有更多了~
  93. </view>
  94. </tm-sheet>
  95. </view>
  96. <view v-if="gouwuche.length!=0" class="fudong" @click="qugowuche">
  97. <image src="../../static/img/87.png" mode="widthFix"></image>
  98. <view class="shuzigwc">{{gouwuche.length}}</view>
  99. </view>
  100. <!-- <view style="width:100%;height:60px;"></view> -->
  101. <!-- 弹出层消息 -->
  102. <tm-message ref="toast"></tm-message>
  103. </view>
  104. </template>
  105. <script>
  106. import {
  107. myRequest
  108. } from '@/api/request.js'
  109. import qqmapsdk from '../../js_sdk/qqmap-wx-jssdk.js'
  110. const QQMapWX = new qqmapsdk({
  111. key: 'KNABZ-OAVCJ-O5IFJ-KBNST-SVIIZ-2EB3G'
  112. });
  113. export default {
  114. data() {
  115. return {
  116. isBottom: false,
  117. current: 1,
  118. activeIndex: 0,
  119. soso: '',
  120. addr: ['江西省', '南昌市', '西湖区'],
  121. value: '',
  122. list: [],
  123. list1: [],
  124. list2: ['热门', '折扣'],
  125. list3: [],
  126. list4: [],
  127. list5: ['推荐单品'],
  128. test: [],
  129. typeclick: 1, //1加入购物车,2购物车
  130. gouwuche: [],
  131. page: 1,
  132. };
  133. },
  134. onLoad() {
  135. },
  136. onShow() {
  137. this.getGwc()
  138. },
  139. created() {
  140. this.sys = uni.getSystemInfoSync();
  141. this.getSort()
  142. this.getBanner()
  143. this.changeTab(1);
  144. this.getHot();
  145. this.getRecommend()
  146. this.getGwc()
  147. this.getCity()
  148. },
  149. onReachBottom() {
  150. this.loadMore()
  151. },
  152. methods: {
  153. getCity() {
  154. var that = this;
  155. uni.getLocation({
  156. type: 'wgs84',
  157. geocode: true,
  158. success: (res) => {
  159. console.log("获取经纬度成功");
  160. this.latitude = res.latitude;
  161. this.longitude = res.longitude;
  162. },
  163. fail: () => {
  164. console.log("获取经纬度失败");
  165. },
  166. complete: () => {
  167. // 解析地址
  168. QQMapWX.reverseGeocoder({
  169. location: {
  170. latitude: this.latitude,
  171. longitude: this.longitude
  172. },
  173. success: function(res) {
  174. console.log("解析地址成功");
  175. console.log(res);
  176. // 省
  177. let province = res.result.ad_info.province;
  178. // 市
  179. let city = res.result.ad_info.city;
  180. //区
  181. let district = res.result.ad_info.district;
  182. that.addr = [province, city, district];
  183. console.log(province);
  184. console.log(city);
  185. console.log(district);
  186. },
  187. fail: function(res) {
  188. uni.showToast({
  189. title: '定位失败',
  190. duration: 2000,
  191. icon: "none"
  192. })
  193. console.log(res);
  194. },
  195. complete: function(res) {
  196. console.log(res);
  197. }
  198. })
  199. }
  200. })
  201. },
  202. getGwc() {
  203. let that = this;
  204. myRequest({
  205. url: "/api/ShopCart/shopCartList",
  206. method: 'get',
  207. data: that.reqData
  208. }).then(res => {
  209. if (res.data.code == 200) {
  210. that.gouwuche = res.data.data;
  211. } else {
  212. that.gouwuche = []
  213. }
  214. })
  215. },
  216. getBanner() {
  217. let that = this;
  218. myRequest({
  219. url: "/api/Banner/bannerList",
  220. method: 'get',
  221. data: that.reqData
  222. }).then(res => {
  223. if (res.data.code == 200) {
  224. res.data.data.forEach(item => {
  225. that.list.push({
  226. src: item.image,
  227. })
  228. })
  229. } else {
  230. that.$refs.toast.show({
  231. model: 'error',
  232. label: res.data.msg
  233. })
  234. }
  235. })
  236. },
  237. //获取分类
  238. getSort() {
  239. let that = this;
  240. myRequest({
  241. url: "/api/ShopGoods/getMallClassification",
  242. method: 'get',
  243. data: that.reqData
  244. }).then(res => {
  245. if (res.data.code == 200) {
  246. res.data.data.forEach(item => {
  247. that.list3.push({
  248. icon: item.image,
  249. text: item.category_name
  250. })
  251. })
  252. } else {
  253. that.$refs.toast.show({
  254. model: 'error',
  255. label: res.data.msg
  256. })
  257. }
  258. })
  259. },
  260. // 热门、折扣
  261. changeTab(activeIndex) {
  262. let that = this;
  263. myRequest({
  264. url: "/api/ShopGoods/thenBuckle",
  265. method: 'post',
  266. data: {
  267. 'type': that.activeIndex + 1
  268. }
  269. }).then(res => {
  270. if (res.data.code == 200) {
  271. that.list1 = [];
  272. res.data.data.forEach(item => {
  273. that.list1.push({
  274. icon: item.image,
  275. text: item.category_name
  276. })
  277. })
  278. } else {
  279. that.$refs.toast.show({
  280. model: 'error',
  281. label: res.data.msg
  282. })
  283. }
  284. })
  285. },
  286. // 获取热门下商品
  287. getHot() {
  288. let that = this;
  289. myRequest({
  290. url: "/api/ShopGoods/popularGoods",
  291. method: 'get',
  292. }).then(res => {
  293. if (res.data.code == 200) {
  294. console.log(res.data.data, '22');
  295. res.data.data.forEach(item => {
  296. that.list4.push({
  297. icon: item.image,
  298. text: item.goods_name,
  299. id: item.id,
  300. category_id: item.category_id,
  301. jie: item.sale_price,
  302. sale_num: item.sale_num,
  303. stock_num: item.stock_num
  304. })
  305. })
  306. that.list4 = that.list4.slice(0, 3);
  307. } else {
  308. that.$refs.toast.show({
  309. model: 'error',
  310. label: res.data.msg
  311. })
  312. }
  313. })
  314. },
  315. // 获取推荐单品列表
  316. getRecommend() {
  317. this.page = 1;
  318. let that = this;
  319. that.test = [];
  320. myRequest({
  321. url: "/api/ShopGoods/recommend",
  322. method: 'get',
  323. data: {
  324. page: that.page
  325. }
  326. }).then(res => {
  327. console.log(res.data.data);
  328. if (res.data.code == 200) {
  329. res.data.data.list.forEach(item => {
  330. that.test.push({
  331. img: item.image,
  332. title: item.goods_name,
  333. price: item.sale_price,
  334. id: item.id,
  335. category_id: item.category_id,
  336. sale_num: item.sale_num,
  337. stock_num: item.stock_num,
  338. is_recommend: item.is_recommend,
  339. })
  340. })
  341. } else {
  342. that.$refs.toast.show({
  343. model: 'error',
  344. label: res.data.msg
  345. })
  346. }
  347. })
  348. },
  349. // 加载更多
  350. loadMore() {
  351. if (this.isBottom) return;
  352. this.page++;
  353. let that = this;
  354. myRequest({
  355. url: "/api/ShopGoods/recommend",
  356. method: 'get',
  357. data: {
  358. page: that.page
  359. }
  360. }).then(res => {
  361. console.log(res.data.data);
  362. if (res.data.code == 200) {
  363. if (that.test.length < res.data.data.count) {
  364. res.data.data.list.forEach(item => {
  365. that.test.push({
  366. img: item.image,
  367. title: item.goods_name,
  368. price: item.sale_price,
  369. id: item.id,
  370. category_id: item.category_id,
  371. sale_num: item.sale_num,
  372. stock_num: item.stock_num,
  373. is_recommend: item.is_recommend,
  374. })
  375. })
  376. console.log(that.test, '下拉架子啊');
  377. } else {
  378. that.isBottom = true;
  379. that.page--;
  380. }
  381. } else {
  382. that.page--;
  383. that.isBottom = false;
  384. that.$refs.toast.show({
  385. model: 'error',
  386. label: res.data.msg
  387. })
  388. }
  389. })
  390. },
  391. tiaozhuan() {
  392. uni.navigateTo({
  393. url: "/pages/gengduo/index",
  394. })
  395. },
  396. // 广告详情
  397. xiangqing() {
  398. uni.navigateTo({
  399. url: "/pages/shopdetail/index",
  400. })
  401. },
  402. // 去商品详情页
  403. goXiangQing(data) {
  404. console.log(data);
  405. uni.navigateTo({
  406. url: "/pages/shopdetail/index?id=" + data.id + '&classId=' + data.category_id,
  407. })
  408. },
  409. lunboFun(e) {
  410. this.current = e;
  411. },
  412. okCity(e) {
  413. console.log(e);
  414. this.addr = e;
  415. },
  416. qugowuche() {
  417. uni.navigateTo({
  418. url: "/pages/gouwuche/index",
  419. })
  420. },
  421. sosoFun() {
  422. uni.navigateTo({
  423. url: "/pages/shopsoso/index",
  424. })
  425. },
  426. shang() {
  427. this.$refs.a_5.play()
  428. this.current = this.current + 1;
  429. },
  430. xia() {
  431. this.$refs.a_1.play()
  432. this.current = this.current - 1;
  433. },
  434. jiarufuFun(data) {
  435. var that = this;
  436. console.log(data)
  437. if (data.type == 2) {
  438. myRequest({
  439. url: "/api/ShopCart/addShopCart",
  440. method: 'post',
  441. data: {
  442. goods_id: data.data.id,
  443. goods_name: data.data.title,
  444. goods_image: data.data.img,
  445. goods_price: data.data.price,
  446. goods_num: 1
  447. }
  448. }).then(res => {
  449. if (res.data.code == 200) {
  450. that.$refs.toast.show({
  451. model: 'success',
  452. label: res.data.msg
  453. })
  454. that.getGwc()
  455. } else {
  456. that.$refs.toast.show({
  457. model: 'error',
  458. label: res.data.msg
  459. })
  460. }
  461. })
  462. }
  463. // else {
  464. // uni.navigateTo({
  465. // url: "/pages/shopdetail/index",
  466. // })
  467. // }
  468. },
  469. zhonglei(e) {
  470. uni.navigateTo({
  471. url: "/pages/gengduo/index",
  472. })
  473. }
  474. },
  475. }
  476. </script>
  477. <style lang="scss">
  478. /deep/ .tm-menubars .body {
  479. background-color: #1b1b1b !important;
  480. }
  481. /deep/ .icon-search {
  482. font-size: 23px !important;
  483. color: #8E8E93 !important;
  484. }
  485. /deep/ .tm-search {
  486. width: 80%;
  487. background-color: #414141 !important;
  488. border-radius: 10px;
  489. }
  490. /deep/ .tm-search .grey-darken-5 {
  491. background-color: #414141 !important;
  492. }
  493. .dingwei {
  494. width: 21%;
  495. margin-top: 3%;
  496. }
  497. .shuruk {
  498. width: 77%;
  499. }
  500. .sousuo {
  501. width: 94%;
  502. margin: 0 auto;
  503. }
  504. .qiehuan {
  505. width: 40px;
  506. height: 40px;
  507. }
  508. .lunbo {
  509. position: relative;
  510. }
  511. .anniu1 {
  512. position: absolute;
  513. top: 0px;
  514. z-index: 9999;
  515. top: 43%;
  516. left: 0;
  517. }
  518. .anniu2 {
  519. position: absolute;
  520. top: 0px;
  521. z-index: 9999;
  522. top: 43%;
  523. right: 0;
  524. }
  525. /deep/ .jiaoxi {
  526. margin: 0 !important;
  527. padding: 8px !important;
  528. }
  529. /deep/ .tm-col {
  530. width: 20% !important;
  531. }
  532. .yifu1 {
  533. width: 40%;
  534. }
  535. .yifu2 {
  536. width: 58%;
  537. }
  538. .yifu1 image,
  539. .yifu21 {
  540. width: 100%;
  541. }
  542. .xiao {
  543. margin-top: 15px !important;
  544. }
  545. /deep/ .qiehuan1 .text-primary {
  546. color: white !important;
  547. }
  548. .guanggao {
  549. position: relative;
  550. }
  551. .wenzi {
  552. position: absolute;
  553. bottom: 1px;
  554. right: 0px;
  555. background: #000000;
  556. width: 140px;
  557. height: 55px;
  558. font-size: 14px;
  559. text-align: center;
  560. }
  561. /deep/ .jiage {
  562. background: #1b1b1b;
  563. }
  564. /deep/ .shangpin .white.bk {
  565. background-color: #1b1b1b !important;
  566. }
  567. /deep/ .shangpin .tm-cartCellListFood {
  568. padding: 0px 0px 15px 0px !important;
  569. margin-top: 5px !important;
  570. margin-bottom: 20px !important;
  571. border-bottom: 1px solid #303030;
  572. }
  573. /deep/ .shangpin .border-t-1.bk {
  574. border-top: 1px solid #1b1b1b !important;
  575. }
  576. /deep/ .shangpin .round-3 {
  577. width: 90px !important;
  578. height: 90px !important;
  579. }
  580. /deep/ .shangpin .tm-cartCellListFood-img {
  581. width: 90px !important;
  582. height: 90px !important;
  583. }
  584. .fudong {
  585. position: fixed;
  586. right: 30px;
  587. bottom: 80px;
  588. background: #0DABF2;
  589. width: 60px;
  590. height: 60px;
  591. border-radius: 30px;
  592. text-align: center;
  593. }
  594. .fudong image {
  595. width: 40px;
  596. margin-top: 6px;
  597. }
  598. .shuzigwc {
  599. color: white;
  600. font-weight: 700;
  601. position: absolute;
  602. right: 5px;
  603. background: red;
  604. padding: 2px;
  605. border-radius: 30px;
  606. top: 2px;
  607. width: 15px;
  608. height: 15px;
  609. font-size: 12px;
  610. }
  611. /deep/ .shangpin .title {
  612. color: white !important;
  613. }
  614. /deep/ .shangpin .text-red {
  615. color: white !important;
  616. }
  617. </style>