index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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" :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. <tm-search v-model="soso" class="fr shuruk" color="white" confirm-text="" @click="sosoFun"></tm-search>
  13. </view>
  14. <view style="clear: both;"></view>
  15. </view>
  16. <view class="lunbo">
  17. <tm-swiper :previmage="false" @change="lunboFun" :list="list" :height="400" :current="current"></tm-swiper>
  18. <tm-translate class="anniu1 fl" :auto="true" ref="a_1" :duration="80" animation-name="zoomIn">
  19. <image v-if="current!=0" @click="xia()" class="qiehuan" src="/static/img/68.png" mode="widthFix"></image>
  20. </tm-translate>
  21. <tm-translate class="anniu2 fr" :auto="true" ref="a_5" :duration="80" animation-name="zoomIn">
  22. <image v-if="current<(list.length-1)" @click="shang()" class="qiehuan" src="/static/img/67.png" mode="widthFix"></image>
  23. </tm-translate>
  24. </view>
  25. <view class="zhuti">
  26. <tm-sheet :shadow="24" class="jiaoxi">
  27. <tm-grid @change="zhonglei" class="mt-20 mb-20" :grid="5" :list="list3" :icon-size="120" font-color="white"></tm-grid>
  28. </tm-sheet>
  29. <!-- <tm-sheet :shadow="24" class="jiaoxi xiao">
  30. <view class="yifu1 fl">
  31. <image src="/static/img/78.png" mode="widthFix"></image>
  32. </view>
  33. <view class="yifu2 fr">
  34. <image class="yifu21" src="/static/img/77.png" mode="widthFix"></image>
  35. <view>
  36. <image style="width:50%;" src="/static/img/75.png" mode="widthFix"></image>
  37. <image style="width:50%;" class="yifu21" src="/static/img/76.png" mode="widthFix"></image>
  38. </view>
  39. </view>
  40. <view style="clear: both;"></view>
  41. </tm-sheet> -->
  42. <tm-sheet :shadow="24" class="jiaoxi xiao">
  43. <tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list2" range-key="title" @change="changeTab(activeIndex)"></tm-tabs>
  44. </tm-sheet>
  45. <tm-sheet :shadow="24" class="jiaoxi xiao" style="height:160px;">
  46. <tm-dragGrid :list="list1" :col="3" disabled="false" class="mt-40 mb-40 remen" :icon-size="160" v-if="list1.length!=0">
  47. <template v-slot:default="{item}">
  48. <view class="flex-center flex-col" @click="tiaozhuan()">
  49. <tm-icons :size="160" :name="item.icon" :color="item.color"></tm-icons>
  50. <text class="text-size-m text-white pt-10">{{item.text}}</text>
  51. <text class="text-size-m text-white pt-10">{{item.jie}}</text>
  52. </view>
  53. </template>
  54. </tm-dragGrid>
  55. </tm-sheet>
  56. </view>
  57. <view class="guanggao" @click="xiangqing">
  58. <image style="width:100%;" src="/static/img/82.png" mode="widthFix"></image>
  59. <view class="wenzi">
  60. <view class="mt-10">额外打九折</view>
  61. <view>高达75%的折扣!</view>
  62. </view>
  63. </view>
  64. <view style="height:160px;" class="mt-40 jiage pt-40">
  65. <tm-dragGrid :list="list4" :col="3" disabled="false" class="remen" :icon-size="160" v-if="list4.length!=0">
  66. <template v-slot:default="{item}">
  67. <view class="flex-center flex-col" @click="xiangqing">
  68. <tm-icons :size="200" :name="item.icon" :color="item.color"></tm-icons>
  69. <text class="text-size-m text-white pt-10">{{item.text}}</text>
  70. <text class="text-size-m text-white pt-10">{{item.jie}}</text>
  71. </view>
  72. </template>
  73. </tm-dragGrid>
  74. </view>
  75. <tm-sheet :shadow="24" class="jiaoxi xiao">
  76. <tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list5" range-key="title"></tm-tabs>
  77. </tm-sheet>
  78. <!-- 单品 -->
  79. <view class="zhuti shangpin">
  80. <tm-sheet :padding="[0, 0]" class="jiaoxi xiao">
  81. <tm-cartCellListFood v-on:jiaruFun="jiarufuFun" v-for="item in test" :typeclick="typeclick" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
  82. </tm-sheet>
  83. </view>
  84. <view v-if="gouwuche.length!=0" class="fudong" @click="qugowuche">
  85. <image src="../../static/img/87.png" mode="widthFix"></image>
  86. <view class="shuzigwc">{{gouwuche.length}}</view>
  87. </view>
  88. <view style="width:100%;height:60px;"></view>
  89. <!-- 弹出层消息 -->
  90. <tm-message ref="toast"></tm-message>
  91. </view>
  92. </template>
  93. <script>
  94. import{myRequest} from '@/api/request.js'
  95. export default {
  96. data() {
  97. return {
  98. current:1,
  99. activeIndex:0,
  100. soso:'',
  101. addr:['江西省','南昌市','西湖区'],
  102. value:'',
  103. list:[],
  104. list1:[],
  105. list2:[ '热门','折扣'],
  106. list3:[],
  107. list4:[],
  108. list5:[ '推荐单品'],
  109. test: [],
  110. typeclick:1,//1加入购物车,2购物车
  111. gouwuche:[],
  112. };
  113. },
  114. onLoad() {
  115. },
  116. onShow() {
  117. this.getGwc()
  118. },
  119. created() {
  120. this.sys = uni.getSystemInfoSync();
  121. this.getSort()
  122. this.getBanner()
  123. this.changeTab(1);
  124. this.getHot();
  125. this.getRecommend()
  126. this.getGwc()
  127. },
  128. methods: {
  129. getGwc(){
  130. let that = this;
  131. myRequest({
  132. url: "/api/ShopCart/shopCartList",
  133. method: 'get',
  134. data: that.reqData
  135. }).then(res => {
  136. if (res.data.code == 200) {
  137. that.gouwuche=res.data.data;
  138. } else {
  139. that.gouwuche=[]
  140. }
  141. })
  142. },
  143. getBanner(){
  144. let that = this;
  145. myRequest({
  146. url: "/api/Banner/bannerList",
  147. method: 'get',
  148. data: that.reqData
  149. }).then(res => {
  150. if (res.data.code == 200) {
  151. res.data.data.forEach(item => {
  152. that.list.push({
  153. src: item.image,
  154. })
  155. })
  156. } else {
  157. that.$refs.toast.show({
  158. model: 'error',
  159. label: res.data.msg
  160. })
  161. }
  162. })
  163. },
  164. //获取分类
  165. getSort(){
  166. let that = this;
  167. myRequest({
  168. url: "/api/ShopGoods/getMallClassification",
  169. method: 'get',
  170. data: that.reqData
  171. }).then(res => {
  172. if (res.data.code == 200) {
  173. res.data.data.forEach(item => {
  174. that.list3.push({
  175. icon: item.image,
  176. text: item.category_name
  177. })
  178. })
  179. } else {
  180. that.$refs.toast.show({
  181. model: 'error',
  182. label: res.data.msg
  183. })
  184. }
  185. })
  186. },
  187. // 热门、折扣
  188. changeTab(activeIndex){
  189. let that = this;
  190. myRequest({
  191. url: "/api/ShopGoods/thenBuckle",
  192. method: 'post',
  193. data: {
  194. 'type':that.activeIndex+1
  195. }
  196. }).then(res => {
  197. if (res.data.code == 200) {
  198. that.list1=[];
  199. res.data.data.forEach(item => {
  200. that.list1.push({
  201. icon: item.image,
  202. text:item.category_name
  203. })
  204. })
  205. } else {
  206. that.$refs.toast.show({
  207. model: 'error',
  208. label: res.data.msg
  209. })
  210. }
  211. })
  212. },
  213. getHot(){
  214. let that = this;
  215. myRequest({
  216. url: "/api/ShopGoods/popularGoods",
  217. method: 'get',
  218. }).then(res => {
  219. if (res.data.code == 200) {
  220. res.data.data.forEach(item => {
  221. that.list4.push({
  222. icon: item.image,
  223. text:item.goods_name,
  224. // jie:item.sale_price
  225. })
  226. })
  227. } else {
  228. that.$refs.toast.show({
  229. model: 'error',
  230. label: res.data.msg
  231. })
  232. }
  233. })
  234. },
  235. getRecommend(){
  236. let that = this;
  237. myRequest({
  238. url: "/api/ShopGoods/recommend",
  239. method: 'get',
  240. }).then(res => {
  241. if (res.data.code == 200) {
  242. res.data.data.forEach(item => {
  243. that.test.push({
  244. img: item.image,
  245. title:item.goods_name,
  246. price:item.sale_price,
  247. itemId:item.id
  248. })
  249. })
  250. } else {
  251. that.$refs.toast.show({
  252. model: 'error',
  253. label: res.data.msg
  254. })
  255. }
  256. })
  257. },
  258. tiaozhuan(){
  259. uni.navigateTo({
  260. url: "/pages/gengduo/index",
  261. })
  262. },
  263. xiangqing(e){
  264. uni.navigateTo({
  265. url: "/pages/shopdetail/index",
  266. })
  267. },
  268. lunboFun(e){
  269. this.current=e;
  270. },
  271. okCity(e){
  272. console.log(e);
  273. this.addr = e;
  274. },
  275. qugowuche(){
  276. uni.navigateTo({
  277. url: "/pages/gouwuche/index",
  278. })
  279. },
  280. sosoFun(){
  281. uni.navigateTo({
  282. url: "/pages/shopsoso/index",
  283. })
  284. },
  285. shang(){
  286. this.$refs.a_5.play()
  287. this.current=this.current+1;
  288. },
  289. xia(){
  290. this.$refs.a_1.play()
  291. this.current=this.current-1;
  292. },
  293. jiarufuFun(data){
  294. var that=this;
  295. console.log(data)
  296. if(data.type==2){
  297. myRequest({
  298. url: "/api/ShopCart/addShopCart",
  299. method:'post',
  300. data:{
  301. goods_id:data.data.itemId,
  302. goods_name:data.data.title,
  303. goods_image:data.data.img,
  304. goods_price:data.data.price,
  305. goods_num:1
  306. }
  307. }).then(res => {
  308. if (res.data.code == 200) {
  309. that.$refs.toast.show({model:'success',label:res.data.msg})
  310. that.getGwc()
  311. }else{
  312. that.$refs.toast.show({model:'error',label:res.data.msg})
  313. }
  314. })
  315. }else{
  316. uni.navigateTo({
  317. url: "/pages/shopdetail/index",
  318. })
  319. }
  320. },
  321. zhonglei(e){
  322. uni.navigateTo({
  323. url: "/pages/gengduo/index",
  324. })
  325. }
  326. },
  327. }
  328. </script>
  329. <style lang="scss">
  330. /deep/ .tm-menubars .body{
  331. background-color: #1b1b1b !important;
  332. }
  333. /deep/ .icon-search{
  334. font-size: 23px !important;
  335. color: #8E8E93 !important;
  336. }
  337. /deep/ .tm-search{
  338. width: 80%;
  339. background-color: #414141 !important;
  340. border-radius: 10px;
  341. }
  342. /deep/ .tm-search .grey-darken-5{
  343. background-color: #414141 !important;
  344. }
  345. .dingwei{width: 21%;margin-top:3%;}
  346. .shuruk{width: 77%;}
  347. .sousuo{width:94%;margin:0 auto;}
  348. .qiehuan{width:40px;height:40px;}
  349. .lunbo{position: relative;}
  350. .anniu1{position: absolute;top:0px;z-index: 9999;top:43%;left:0;}
  351. .anniu2{position: absolute;top:0px;z-index: 9999;top:43%;right:0;}
  352. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;}
  353. /deep/ .tm-col{width: 20% !important;}
  354. .yifu1{width: 40%;}
  355. .yifu2{width: 58%;}
  356. .yifu1 image,.yifu21{width: 100%;}
  357. .xiao{margin-top:15px !important;}
  358. /deep/ .qiehuan1 .text-primary{color: white !important;}
  359. .guanggao{position: relative;}
  360. .wenzi{position: absolute;bottom:1px;right:0px;background: #000000;
  361. width: 140px;
  362. height: 55px;
  363. font-size: 14px;
  364. text-align: center;
  365. }
  366. /deep/ .jiage{background: #1b1b1b;}
  367. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  368. /deep/ .shangpin .tm-cartCellListFood{ padding: 0px 0px 15px 0px !important;
  369. margin-top: 5px !important;margin-bottom: 20px !important;
  370. border-bottom: 1px solid #303030;}
  371. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  372. /deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
  373. /deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
  374. .fudong{position: fixed;right:30px;bottom:80px;background: #0DABF2;width: 60px;height:60px;
  375. border-radius: 30px;text-align: center;}
  376. .fudong image{width:40px;margin-top: 6px;}
  377. .shuzigwc{color: white;font-weight: 700;position: absolute;right:5px;background: red;
  378. padding:2px;border-radius: 30px;top:2px;width:15px;height:15px;font-size: 12px;}
  379. /deep/ .shangpin .title{color: white !important;}
  380. /deep/ .shangpin .text-red{color: white !important;}
  381. </style>