You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1400 lines
33 KiB

6 months ago
  1. <template>
  2. <view>
  3. <!-- 提示添加小程序 -->
  4. <addtip :tip="tip" :duration="duration" />
  5. <!-- 搜索框 -->
  6. <!-- 拖拽悬浮球 -->
  7. <view class="kf">
  8. <button class="kfbt" open-type="contact">
  9. <image src="http://m2.chinause.cn/mini/baixmini/img/kefubt.png" style="width: 100upx;height: 100upx;" /></button>
  10. </view>
  11. <view class="top">
  12. <view class="main-box" v-if="userInfo.khnum>1">
  13. <zqs-select
  14. :multiple="false"
  15. :list="options"
  16. :showSearch="false"
  17. label-key="label"
  18. value-key="value"
  19. title="选择客户"
  20. clearable
  21. v-model="importUserId"
  22. @input="getValue2($event)"
  23. ></zqs-select>
  24. </view>
  25. <view class="input-box" @click="toSearch()">
  26. <input placeholder="请输入商品名称" placeholder-style="color:#c0c0c0;" disabled="disabled" />
  27. <cjl-icon>&#xe60b;</cjl-icon>
  28. </view>
  29. </view>
  30. <!-- 轮播图方式一 -->
  31. <swiper class="card-swiper" :indicator-dots="false" circular autoplay interval="3000" duration="500" previous-margin="30px"
  32. next-margin="30px" @change="cardSwiper">
  33. <swiper-item v-for="(item,index) in banner" :key="index" :class="cardCur==index?'cur':''">
  34. <view class="swiper-item" @click="topcate(item.url)">
  35. <hyp-image cname="image" :realSrc="item.images"></hyp-image>
  36. </view>
  37. </swiper-item>
  38. </swiper>
  39. <!-- 轮播图方式二 -->
  40. <!-- <swiper class="swiper" :indicator-dots="true" circular autoplay interval="3000" duration="500">
  41. <swiper-item @tap="onBanner" v-for="(item,index) in banner" :key="index">
  42. <view class="swiper-item">
  43. <hyp-image cname="image" :realSrc="item.images"></hyp-image>
  44. </view>
  45. </swiper-item>
  46. </swiper> -->
  47. <!-- 分类列表 -->
  48. <view class="type">
  49. <view class="item" v-for="item in typeList" :key="item.id" @tap="toCategory(item.id)">
  50. <hyp-image cname="image" :realSrc="item.images"></hyp-image>
  51. <text class="fltext">{{item.fenlmc}}</text>
  52. </view>
  53. </view>
  54. <!-- 公告区 -->
  55. <view>
  56. <uni-notice-bar @click="getMore" show-icon="true" speed="12" scrollable="true" single="true" :color="color"
  57. :backgroundColor="backcolor" :text="text">
  58. </uni-notice-bar>
  59. </view>
  60. <!-- 广告图
  61. <view class="ad-1">
  62. <image src="http://m2.chinause.cn/mini/baixmini/img/adv.jpg" mode="scaleToFill"></image>
  63. </view>-->
  64. <!-- 推荐商品 -->
  65. <view class="tjgoodlist">
  66. <view class="title">
  67. <image src="../../static/img/loveicon.png"></image>
  68. <text>推荐商品</text>
  69. <image src="../../static/img/loveicon.png"></image>
  70. </view>
  71. <view class="tj_list" v-for="(product,index) in tjproductList" :key="product.id" @click="toGoods(product)">
  72. <view class="tjleft">
  73. <image :src="product.img"></image>
  74. </view>
  75. <view class="tjright">
  76. <view style="margin-bottom: 20upx;">{{ product.mc }}&nbsp;{{product.gg}}{{product.dw}}</view>
  77. <view :class="product.miaosstyle" @tap.stop="changemiaosstyle(index)">
  78. {{product.miaos}}
  79. </view>
  80. <view>
  81. <text v-if="product.price!=''">{{ product.price }}{{product.dw}}</text>
  82. <!--<text style="margin: 0 18upx;">库存{{ product.kcnum }}</text>-->
  83. </view>
  84. <!-- <view>
  85. <text class="sdtext">{{ product.sdtext }}</text>
  86. <text class="sellnum">售量&nbsp;{{ product.sellnum }}</text>
  87. </view> -->
  88. <view style="padding: 0upx 8upx; color: grey; display: flex;align-items: center;" @tap.stop v-if="product.inputnum">
  89. <input style="font-size: 28upx; color: #41A863;" type="text" :value="product.bz" @input="inputchangeBz($event,product.bz,product.id,product.kcnum,2,index)" placeholder="输入备注">
  90. <input style="font-size: 28upx; color: #41A863;" type="text" :value="product.fudw" @input="inputchangeFudw($event,product.fudw,product.id,product.kcnum,2,index)" placeholder="输入副单位">
  91. </view>
  92. <view class="tjroot">
  93. <view class="p-b-btn" :class="{active: product.iscollect}" @click.stop="toFavorite(product.id,index,0)">
  94. <text class="yticon icon-shoucang"></text>
  95. </view>
  96. <!-- <view class="nosell" v-if="product.kcnum==0"><text>已售空</text></view> -->
  97. <view class="number" v-if="product.kcnum">
  98. <view class="sub" @tap.stop="sub(product.id)" >
  99. <view class="jian">-</view>
  100. </view>
  101. <view class="input" @tap.stop="discard" >
  102. <input type="digit" v-model="product.inputnum==0?'':product.inputnum" @input="inputchange($event,product.inputnum,product.id,product.kcnum,0)" />
  103. </view>
  104. <view class="add" @tap.stop="add(product.id,0)">
  105. <view class="jia">
  106. <image src="../../static/img/addicon.png"></image>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 猜你喜欢列表 -->
  115. <view class="goods-list" v-if="productList!=''">
  116. <view class="title">
  117. <image src="../../static/img/loveicon.png"></image>
  118. <text>猜你喜欢</text>
  119. <image src="../../static/img/loveicon.png"></image>
  120. </view>
  121. <view class="product-list">
  122. <view class="product" v-for="(product,index) in productList" :key="product.id" @click="toGoods(product)">
  123. <image :src="product.img"></image>
  124. <view class="name">{{ product.mc }}&nbsp;{{product.gg}}{{product.dw}}</view>
  125. <view :class="product.miaosstyle" @tap.stop="changemiaosstyle(index)">
  126. {{product.miaos}}
  127. </view>
  128. <!-- <view style="margin-left: 15upx;">
  129. <text class="sdtext">{{ product.sdtext }}</text>
  130. <text class="sellnum">售量&nbsp;{{ product.sellnum }}</text>
  131. </view>-->
  132. <view class="info">
  133. <view class="price" v-if="product.price!=''">{{ product.price }}{{product.dw}}</view>
  134. <!--<view class="slogan">库存&nbsp;{{ product.kcnum }}</view>-->
  135. </view>
  136. <view style="padding: 0upx 8upx;color: grey;" @tap.stop v-if="product.inputnum">
  137. <input style="font-size: 28upx; color: #41A863;" type="text" :value="product.bz" @input="inputchangeBz($event,product.bz,product.id,product.kcnum,2,index)" placeholder="输入备注">
  138. <input style="font-size: 28upx; color: #41A863;" type="text" :value="product.fudw" @input="inputchangeFudw($event,product.fudw,product.id,product.kcnum,2,index)" placeholder="输入副单位">
  139. </view>
  140. <!-- <view class="nosell" v-if="product.kcnum==0"><text>已售空</text></view> -->
  141. <view class="number" v-if="product.kcnum">
  142. <view class="p-b-btn" :class="{active: product.iscollect}" @click.stop="toFavorite(product.id,index,1)">
  143. <text class="yticon icon-shoucang" style="margin-right: 15upx;"></text>
  144. </view>
  145. <view class="sub" @tap.stop="sub(product.id)" >
  146. <view class="jian">-</view>
  147. </view>
  148. <view class="input" @tap.stop="discard" >
  149. <input type="digit" v-model="product.inputnum==0?'':product.inputnum" @input="inputchange($event,product.inputnum,product.id,product.kcnum,1)" />
  150. </view>
  151. <view class="add" @tap.stop="add(product.id,1)">
  152. <view class="jia">
  153. <image src="../../static/img/addicon.png"></image>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. <!-- 介绍 -->
  161. <!-- <view class="task-title">
  162. <view class="top">
  163. <view class="left">
  164. <view></view>
  165. <text>产品&业务介绍</text>
  166. </view>
  167. <view class="right">
  168. <text>更多</text>
  169. <hyp-icon color="#B0B8C7">&#xe603;</hyp-icon>
  170. </view>
  171. </view>
  172. </view> -->
  173. <!-- <view class="task-list">
  174. <view class="item" v-for="(item,index) in pcdesc" :key="item.id" @click="todetail(item.id)">
  175. <view class="header">
  176. <view class="left">
  177. <hyp-image cname="avatar" :realSrc="'../../static/img/desc_icon.png'"></hyp-image>
  178. <text>{{item.type}}</text>
  179. </view>
  180. <view class="right">
  181. <view class="label"> 23</view>
  182. <view class="label">200</view>
  183. </view>
  184. </view>
  185. <view class="body">
  186. <view class="left">
  187. <view class="title">{{item.title}}</view>
  188. <view class="desc">{{item.contents}}</view>
  189. </view>
  190. <view class="right" v-if="item.img">
  191. <image :src="item.img" style="border-radius: 15upx;"></image>
  192. </view>
  193. </view>
  194. </view>
  195. </view> -->
  196. </view>
  197. </template>
  198. <script>
  199. import addtip from '@/components/struggler-uniapp-add-tip/struggler-uniapp-add-tip.vue';
  200. import dragButton from "@/components/drag-button/drag-button.vue";
  201. import uniNoticeBar from "@/components/uni-notice-bar/uni-notice-bar.vue"
  202. import zqsSelect from '@/components/zqs-select/zqs-select.vue'
  203. export default {
  204. components: {
  205. addtip,
  206. dragButton,
  207. uniNoticeBar,
  208. zqsSelect
  209. },
  210. data() {
  211. return {
  212. bttext: '客服',
  213. tip: "点击「添加小程序」,下次访问更便捷",
  214. duration: 5, //提示添加小程序显示时间
  215. banner: [{
  216. "id": 121,
  217. "title": "母亲节",
  218. "url": "\/pages\/course\/activity?id=101&_from=share_prod_4",
  219. "images": "http:\/\/statictest.pipacode.cn\/a1a7a201905101726438109.gif",
  220. "up_time": "2019-12-14 00:00:00",
  221. "down_time": ""
  222. }],
  223. cardCur: 0,
  224. typeList: [{
  225. "id": 3,
  226. "name": "粮油类",
  227. "sort": 2,
  228. "icon": "http://m2.chinause.cn:8888/8img/mini/liangyou.png"
  229. }],
  230. pcdesc: [],
  231. //猜你喜欢列表
  232. productList: [],
  233. tjproductList: [],
  234. loadingText: '正在加载...',
  235. miaosstyle: 'miaos',
  236. goodsList: [], //购物车商品
  237. text: '欢迎进入中龙小程序商城',
  238. backcolor: '#E8E8E8',
  239. color: '#F23E05',
  240. gg_zezhao: 'none',
  241. gg_model: 'none',
  242. importUserId:[],
  243. value:'',
  244. options:[],
  245. userInfo:[]
  246. }
  247. },
  248. methods: {
  249. async baseinfo(key) {
  250. let reinfo = await this.$api.baseinfo({
  251. action: 'baseinfo',
  252. key: key
  253. });
  254. if (key == 'gscolor') {
  255. this.color = reinfo.data.info
  256. } else if (key == 'gsbgcolor') {
  257. this.backcolor = reinfo.data.info
  258. }
  259. },
  260. //拖拽悬浮球相关事件开始
  261. btnClick() {
  262. console.log('btnClick');
  263. },
  264. btnTouchstart() {
  265. console.log('btnTouchstart');
  266. },
  267. btnTouchend() {
  268. console.log('btnTouchend');
  269. },
  270. //拖拽悬浮球相关事件结束
  271. cardSwiper(e) {
  272. this.cardCur = e.detail.current
  273. },
  274. //搜索跳转
  275. toSearch() {
  276. uni.showLoading({
  277. title: '加载中...'
  278. })
  279. uni.navigateTo({
  280. url: `/pages/search/search`
  281. })
  282. uni.hideLoading()
  283. },
  284. //到分类
  285. topcate(url) {
  286. if (url != '#' && url != undefined) {
  287. let tourl = url.split('?');
  288. let ids = tourl[1].split('&');
  289. let dflid = ids[0];
  290. let xflid = ids[1];
  291. getApp().globalData.dflid = dflid;
  292. getApp().globalData.xflid = xflid;
  293. getApp().globalData.tid = 1;
  294. uni.switchTab({
  295. url: tourl[0]
  296. })
  297. }
  298. },
  299. async addcollection(id, index, dotype) {
  300. let userinfo = uni.getStorageSync('userinfo');
  301. let type;
  302. if (dotype == 0) {
  303. type = !this.tjproductList[index].iscollect;
  304. } else {
  305. type = !this.productList[index].iscollect;
  306. }
  307. if (userinfo) {
  308. let redata = await this.$api.addcollection({
  309. action: 'addcollection',
  310. type: type,
  311. uid: userinfo.uid,
  312. id: id
  313. });
  314. uni.showToast({
  315. title: redata.msg,
  316. icon: 'none'
  317. })
  318. if (redata.code == 1) {
  319. if (dotype == 0) {
  320. this.tjproductList[index].iscollect = !this.tjproductList[index].iscollect;
  321. } else {
  322. this.productList[index].iscollect = !this.productList[index].iscollect;
  323. }
  324. }
  325. } else {
  326. uni.navigateTo({
  327. url: '/pages/user/login'
  328. })
  329. }
  330. },
  331. //收藏
  332. toFavorite(id, index, type) {
  333. this.addcollection(id, index, type);
  334. },
  335. //猜你喜欢商品
  336. async getgoodlist() {
  337. let userinfo = uni.getStorageSync('userinfo');
  338. let getdata = await this.$api.getgoodlist({
  339. action: 'goodlist2',
  340. type: 1,
  341. uid: userinfo.uid
  342. });
  343. this.productList = getdata.data.map((item, index) => {
  344. item.checked = false
  345. item.shownum = 0
  346. item.miaosstyle = 'miaos'
  347. return item
  348. });
  349. this.checkshownum();
  350. },
  351. //获取推荐商品
  352. async gettjgoodlist() {
  353. let userinfo = uni.getStorageSync('userinfo');
  354. let getdata = await this.$api.getgoodlist({
  355. action: 'goodlist2',
  356. type: 2,
  357. uid: userinfo.uid
  358. });
  359. this.tjproductList = getdata.data.map((item, index) => {
  360. item.checked = false
  361. item.shownum = 0
  362. item.miaosstyle = 'miaos'
  363. return item
  364. });
  365. this.checkshownum();
  366. },
  367. //轮播图
  368. async getbanner() {
  369. let getdata = await this.$api.getbanner({
  370. action: 'banner'
  371. });
  372. if(getdata.code!=0){
  373. this.banner = getdata.data;
  374. }
  375. },
  376. //公告
  377. async getnotice() {
  378. let getdata = await this.$api.notice({
  379. action: 'notice'
  380. });
  381. this.text = getdata.data[0].info;
  382. },
  383. //点击公告
  384. getMore(e) {
  385. uni.showModal({
  386. title: '',
  387. content: this.text,
  388. showCancel: false,
  389. buttonText: '确定',
  390. success: (res) => {
  391. if (res.confirm) {
  392. }
  393. }
  394. })
  395. },
  396. //获取分类导航
  397. async getitem() {
  398. let getdata = await this.$api.getitem({
  399. action: 'item'
  400. });
  401. this.typeList = getdata.data;
  402. },
  403. //获取产品介绍列表
  404. async getcpdesc() {
  405. let getdata = await this.$api.getcpdesc({
  406. action: 'cpdesc'
  407. });
  408. this.pcdesc = getdata.data;
  409. },
  410. //跳详情页
  411. toGoods(good) {
  412. uni.navigateTo({
  413. url: '../product/detail?gid=' + good.id + "&price=" + good.price
  414. })
  415. },
  416. //跳转到产品,改跳分类
  417. toCategory(e) {
  418. getApp().globalData.dflid = e;
  419. getApp().globalData.xflid = 0;
  420. uni.switchTab({
  421. url: '/pages/category/category'
  422. })
  423. },
  424. //文章详细
  425. todetail(e) {
  426. uni.navigateTo({
  427. url: `/pages/advdetail/advdetail?id=` + e
  428. })
  429. },
  430. //点击改变描述显示
  431. changemiaosstyle(index) {
  432. let item = this.productList[index]
  433. item.checked = !item.checked
  434. if (item.miaosstyle == 'miaos') {
  435. item.miaosstyle = 'miaosshow';
  436. } else {
  437. item.miaosstyle = 'miaos';
  438. }
  439. this.$set(this.productList, index, item)
  440. },
  441. //减操作
  442. sub(id) {
  443. let getcartlist = uni.getStorageSync('cartlist');
  444. let isexit = this.findidfromstor(id);
  445. let delid = 0;
  446. for (let i = 0; i < getcartlist.length; i++) {
  447. if (isexit.id == getcartlist[i].id) { //找到商品一样的商品
  448. getcartlist[i].num--; //数量减
  449. if (getcartlist[i].num <= 0) {
  450. //删除当前商品缓存
  451. getcartlist.splice(i, 1);
  452. uni.setStorageSync('cartlist', getcartlist)
  453. break; //跳出循环
  454. } else {
  455. getcartlist[i].total = parseFloat((getcartlist[i].num * getcartlist[i].price) * 100) / 100
  456. uni.setStorageSync('cartlist', getcartlist)
  457. break; //跳出循环
  458. }
  459. }
  460. }
  461. this.checkshownum();
  462. },
  463. // 增加数量,type 0-推荐商品,1-猜你喜欢商品
  464. add(id, type) {
  465. let getcartlist = uni.getStorageSync('cartlist');
  466. //首次加购物车
  467. if (getcartlist == '') {
  468. this.goodsList = [];
  469. if (type == 1) {
  470. this.goodsList.push(this.findarrbyid(id));
  471. } else {
  472. this.goodsList.push(this.findarrbyid_tj(id));
  473. }
  474. //计算每个商品的总价格
  475. this.goodsList.map((item, index) => {
  476. item.total = parseFloat((item.price * item.num) * 100) / 100
  477. });
  478. uni.setStorageSync('cartlist', this.goodsList);
  479. } else {
  480. //已有商品在购物车
  481. let isexit = this.findidfromstor(id);
  482. if (!isexit) {
  483. //购物车中还没当前商品
  484. //不存在
  485. if (type == 1) {
  486. getcartlist.push(this.findarrbyid(id));
  487. } else {
  488. getcartlist.push(this.findarrbyid_tj(id));
  489. }
  490. for (let i = 0; i < getcartlist.length; i++) {
  491. if (id == getcartlist[i].id) {
  492. getcartlist[i].total = parseFloat((getcartlist[i].num * getcartlist[i].price) * 100) / 100
  493. }
  494. }
  495. uni.setStorageSync('cartlist', getcartlist);
  496. } else {
  497. //存在
  498. for (let i = 0; i < getcartlist.length; i++) {
  499. if (isexit.id == getcartlist[i].id) { //找到商品一样的商品
  500. getcartlist[i].num++; //数量自增
  501. if (getcartlist[i].num > getcartlist[i].kcnum) {
  502. uni.showToast({
  503. title: '库存不足!',
  504. icon: 'none'
  505. })
  506. break; //跳出循环
  507. } else {
  508. getcartlist[i].total = parseFloat((getcartlist[i].num * getcartlist[i].price) * 100) / 100
  509. uni.setStorageSync('cartlist', getcartlist)
  510. break; //跳出循环
  511. }
  512. }
  513. }
  514. }
  515. }
  516. this.checkshownum();
  517. },
  518. // input框直接加入购物车
  519. inputadd(id, type,inputnum) {
  520. let getcartlist = uni.getStorageSync('cartlist');
  521. //首次加购物车
  522. if (getcartlist == '') {
  523. this.goodsList = [];
  524. if (type == 1) {
  525. this.goodsList.push(this.findarrbyid(id));
  526. } else {
  527. this.goodsList.push(this.findarrbyid_tj(id));
  528. }
  529. //计算每个商品的总价格
  530. this.goodsList.map((item, index) => {
  531. item.total = parseFloat((item.price * inputnum) * 100) / 100;
  532. item.num = parseFloat(inputnum);
  533. });
  534. uni.setStorageSync('cartlist', this.goodsList);
  535. } else {
  536. //已有商品在购物车
  537. let isexit = this.findidfromstor(id);
  538. if (!isexit) {
  539. //购物车中还没当前商品
  540. //不存在
  541. if (type == 1) {
  542. getcartlist.push(this.findarrbyid(id));
  543. } else {
  544. getcartlist.push(this.findarrbyid_tj(id));
  545. }
  546. for (let i = 0; i < getcartlist.length; i++) {
  547. if (id == getcartlist[i].id) {
  548. getcartlist[i].total = parseFloat((inputnum * getcartlist[i].price) * 100) / 100;
  549. getcartlist[i].num = parseFloat(inputnum);
  550. }
  551. }
  552. uni.setStorageSync('cartlist', getcartlist);
  553. } else {
  554. //存在
  555. for (let i = 0; i < getcartlist.length; i++) {
  556. if (isexit.id == getcartlist[i].id) { //找到商品一样的商品
  557. getcartlist[i].num=inputnum; //数量自增
  558. if (getcartlist[i].num > getcartlist[i].kcnum) {
  559. uni.showToast({
  560. title: '库存不足!',
  561. icon: 'none'
  562. })
  563. break; //跳出循环
  564. } else {
  565. getcartlist[i].total = parseFloat((getcartlist[i].num * getcartlist[i].price) * 100) / 100
  566. uni.setStorageSync('cartlist', getcartlist)
  567. break; //跳出循环
  568. }
  569. }
  570. }
  571. }
  572. }
  573. this.checkshownum();
  574. },
  575. inputchange(inputsl,inputnum, id, kcnum,type) {
  576. inputnum=parseFloat(inputsl.detail.value);
  577. let getcartlist = uni.getStorageSync('cartlist');
  578. if (inputnum > 0) {
  579. if (inputnum > kcnum) {
  580. uni.showToast({
  581. title: '库存不足',
  582. icon: 'none'
  583. })
  584. return;
  585. }
  586. this.inputadd(id,type,inputnum);//input框直接添加购物车
  587. } else {
  588. for (let i = 0; i < getcartlist.length; i++) {
  589. if (id == getcartlist[i].id) { //找到商品一样的商品
  590. getcartlist[i].num = 0;
  591. uni.setStorageSync('cartlist', getcartlist)
  592. break; //跳出循环
  593. }
  594. }
  595. this.checkshownum();
  596. }
  597. },
  598. inputchangeBz(inputsl,inputnum, id, kcnum,type,index) {
  599. inputnum=inputsl.detail.value;
  600. let getcartlist = uni.getStorageSync('cartlist');
  601. let isbz=0;
  602. for (let i = 0; i < getcartlist.length; i++) {
  603. if (id == getcartlist[i].id) { //找到商品一样的商品
  604. getcartlist[i].bz = inputnum;
  605. uni.setStorageSync('cartlist', getcartlist)
  606. isbz=1;
  607. break; //跳出循环
  608. }
  609. }
  610. this.checkshownum();
  611. if(isbz==0){
  612. uni.showToast({title:'请您输入数量后再填备注',icon:'none'});
  613. return;
  614. }
  615. },
  616. inputchangeFudw(inputsl,inputnum, id, kcnum,type,index) {
  617. inputnum=inputsl.detail.value;
  618. let getcartlist = uni.getStorageSync('cartlist');
  619. let is=0;
  620. for (let i = 0; i < getcartlist.length; i++) {
  621. if (id == getcartlist[i].id) { //找到商品一样的商品
  622. getcartlist[i].fudw = inputnum;
  623. uni.setStorageSync('cartlist', getcartlist)
  624. is=1;
  625. break; //跳出循环
  626. }
  627. }
  628. this.checkshownum();
  629. if(is==0){
  630. uni.showToast({title:'请您输入数量后再填副单位',icon:'none'});
  631. return;
  632. }
  633. },
  634. //初始化购物车数据
  635. checkshownum() {
  636. let getcartlist = uni.getStorageSync('cartlist');
  637. let carid = [];let carbz = [];let carfudw = [];
  638. for (let i = 0; i < getcartlist.length; i++) {
  639. carid[getcartlist[i]['id']] = getcartlist[i]['num'];
  640. carbz[getcartlist[i]['id']] = getcartlist[i]['bz'];
  641. carfudw[getcartlist[i]['id']] = getcartlist[i]['fudw'];
  642. }
  643. for (let i = 0; i < this.productList.length; i++) {
  644. if (carid[this.productList[i]['id']]) {
  645. this.$set(this.productList[i], 'inputnum', carid[this.productList[i]['id']])
  646. this.$set(this.productList[i], 'bz', carbz[this.productList[i]['id']])
  647. this.$set(this.productList[i], 'fudw', carfudw[this.productList[i]['id']])
  648. } else {
  649. this.$set(this.productList[i], 'inputnum', 0)
  650. this.$set(this.productList[i], 'bz','')
  651. this.$set(this.productList[i], 'fudw','')
  652. }
  653. }
  654. for (let i = 0; i < this.tjproductList.length; i++) {
  655. if (carid[this.tjproductList[i]['id']]) {
  656. this.$set(this.tjproductList[i], 'inputnum', carid[this.tjproductList[i]['id']])
  657. this.$set(this.tjproductList[i], 'bz', carbz[this.tjproductList[i]['id']])
  658. this.$set(this.tjproductList[i], 'fudw', carfudw[this.tjproductList[i]['id']])
  659. } else {
  660. this.$set(this.tjproductList[i], 'inputnum', 0)
  661. this.$set(this.tjproductList[i], 'bz', '')
  662. this.$set(this.tjproductList[i], 'fudw', '')
  663. }
  664. }
  665. },
  666. //根据数组指定key获取当前数组
  667. findarrbyid(id) {
  668. let arr = this.productList;
  669. for (let i = 0; i < arr.length; i++) {
  670. if (arr[i]['id'] == id) {
  671. //console.log(arr[i],'要保存的东西')
  672. return arr[i];
  673. break; //跳出循环
  674. }
  675. }
  676. },
  677. //推荐商品
  678. findarrbyid_tj(id) {
  679. let arr = this.tjproductList;
  680. for (let i = 0; i < arr.length; i++) {
  681. if (arr[i]['id'] == id) {
  682. //console.log(arr[i],'要保存的东西')
  683. return arr[i];
  684. break; //跳出循环
  685. }
  686. }
  687. },
  688. //从本地存储中根据id获取数组
  689. findidfromstor(id) {
  690. let arr = uni.getStorageSync('cartlist');
  691. for (let i = 0; i < arr.length; i++) {
  692. if (arr[i]['id'] == id) {
  693. return arr[i];
  694. break; //跳出循环
  695. }
  696. }
  697. },
  698. discard() {
  699. //丢弃,防止事件冒泡而设
  700. },
  701. async getColor(){
  702. let reinfo = await this.$api.getitem({
  703. action: 'baseinfocolor'
  704. });
  705. this.color = reinfo.data[0].info
  706. this.backcolor = reinfo.data[1].info
  707. },
  708. async base(){
  709. let baseinfo=await this.$api.baseset({action:'baseinfo',key:'mininame'});
  710. uni.setNavigationBarTitle({
  711. title: baseinfo.data.info,
  712. });
  713. },
  714. init() {
  715. this.getbanner();
  716. this.getitem();
  717. //this.getcpdesc();
  718. // this.getgoodlist();
  719. this.gettjgoodlist();
  720. this.getnotice();
  721. // this.getColor();
  722. // this.baseinfo('gscolor');
  723. // this.baseinfo('gsbgcolor');
  724. this.base();
  725. },
  726. getValue2(e){
  727. this.value = e;
  728. if(!this.value || this.value=='')
  729. {
  730. this.importUserId=this.userInfo.uid;
  731. }else{
  732. let getuserinfo=uni.getStorageSync('userinfo');
  733. if(getuserinfo)
  734. {
  735. let dataObj = getuserinfo;
  736. // 修改特定元素的值
  737. dataObj.uid = this.value;
  738. uni.setStorageSync('userinfo',dataObj);
  739. this.userInfo=dataObj;
  740. }
  741. this.importUserId=this.value;
  742. }
  743. }
  744. },
  745. onShow() {
  746. // this.init();
  747. this.getgoodlist();
  748. this.gettjgoodlist();
  749. this.checkshownum();
  750. // this.baseinfo('gscolor');
  751. // this.baseinfo('gsbgcolor');
  752. let getuserinfo=uni.getStorageSync('userinfo');
  753. //console.log(getuserinfo);
  754. if(getuserinfo!='')
  755. {
  756. this.userInfo=getuserinfo;
  757. this.importUserId=getuserinfo.uid;
  758. this.options=getuserinfo.kharr;
  759. }
  760. },
  761. onLoad(e) {
  762. this.init();
  763. uni.showShareMenu({
  764. complete() {
  765. }
  766. })
  767. }
  768. }
  769. </script>
  770. <style lang="scss">
  771. .gg_zz {
  772. position: fixed;
  773. top: 0;
  774. z-index: 1;
  775. left: 0;
  776. width: 100%;
  777. height: 100%;
  778. background-color: #3c3c3c;
  779. opacity: 0.8;
  780. }
  781. .gg_model {
  782. width: 80%;
  783. color: #666;
  784. z-index: 2;
  785. height: auto;
  786. border-radius: 10px;
  787. opacity: 1;
  788. background-color: white;
  789. position: fixed;
  790. top: 50%;
  791. left: 50%;
  792. transform: translate(-50%, -50%);
  793. padding: 10px;
  794. }
  795. .gg_model text {
  796. margin-bottom: 15px;
  797. font-size: 32rpx;
  798. line-height: 20px;
  799. }
  800. .gg_cennel {
  801. margin: auto;
  802. display: block;
  803. width: 55px;
  804. text-align: center;
  805. border-radius: 5px;
  806. font-size: 35rpx;
  807. color: #50BAFE;
  808. border: 1rpx solid #50BAFE;
  809. height: 60rpx;
  810. line-height: 60rpx;
  811. }
  812. .kefubt {
  813. display: flex;
  814. flex-direction: column;
  815. align-items: center;
  816. justify-content: center;
  817. }
  818. .kf {
  819. .kfbt {
  820. display: flex;
  821. position: fixed;
  822. z-index: 999999;
  823. top: 76%;
  824. right: 0;
  825. margin-right: 3rpx;
  826. background: none;
  827. }
  828. .kfbt::after {
  829. border: 0;
  830. }
  831. }
  832. .logo {
  833. height: 200rpx;
  834. width: 200rpx;
  835. margin-top: 200rpx;
  836. margin-left: auto;
  837. margin-right: auto;
  838. margin-bottom: 50rpx;
  839. }
  840. .text-area {
  841. display: flex;
  842. justify-content: center;
  843. }
  844. // 搜索
  845. .top {
  846. width: 100%;
  847. display: flex;
  848. justify-content: center;
  849. align-items: center;
  850. // position: absolute;
  851. // top: 35upx;
  852. // z-index: 111;
  853. .main-box {
  854. display: flex;
  855. margin: 10rpx;
  856. justify-content: space-between;
  857. background: #fff;
  858. width:25%;
  859. padding: 10rpx;
  860. margin-top:-3px;
  861. text-align: left;
  862. }
  863. .input-box {
  864. width: 70%;
  865. height: 60upx;
  866. background-color: #f5f5f5;
  867. border-radius: 30upx;
  868. position: relative;
  869. display: flex;
  870. align-items: center;
  871. justify-content: space-between;
  872. padding-right: 15upx;
  873. input {
  874. padding-left: 30upx;
  875. height: 28upx;
  876. font-size: 28upx;
  877. }
  878. margin-bottom: 15upx;
  879. }
  880. }
  881. .icon {
  882. font-family: 'HMfont-home' !important;
  883. font-size: 60upx;
  884. font-style: normal;
  885. color: #000000;
  886. &.search {
  887. &:before {
  888. content: '\e628';
  889. }
  890. }
  891. }
  892. .card-swiper {
  893. height: 300upx !important;
  894. swiper-item {
  895. box-sizing: border-box;
  896. padding: 30upx 0upx 20upx;
  897. overflow: initial;
  898. .swiper-item {
  899. @include size(100%);
  900. display: block;
  901. border-radius: 30upx;
  902. transform: scale(0.9);
  903. transition: all 0.2s ease-in 0s;
  904. overflow: hidden;
  905. .image {
  906. @include size(100%);
  907. }
  908. }
  909. &.cur {
  910. .swiper-item {
  911. transform: none;
  912. transition: all 0.2s ease-in 0s;
  913. }
  914. }
  915. }
  916. }
  917. .type {
  918. @include fr();
  919. flex-wrap: wrap;
  920. margin: 20upx;
  921. .item {
  922. flex: 0 0 25%;
  923. @include fc(c, c);
  924. margin-bottom: 20upx;
  925. .image {
  926. @include size(100upx);
  927. margin-bottom: 10upx;
  928. border-radius: 50%;
  929. }
  930. text {
  931. @include font(28upx, #666);
  932. }
  933. }
  934. }
  935. .ad-1 {
  936. width: 100%;
  937. height: 220upx;
  938. padding: 10upx 20upx;
  939. background: #fff;
  940. image {
  941. width: 100%;
  942. height: 100%;
  943. border-radius: 15upx;
  944. }
  945. }
  946. .sellnum {
  947. font-size: 25upx;
  948. padding-left: 15upx;
  949. color: #B9B9B9;
  950. }
  951. .sdtext {
  952. padding: 2upx 8upx;
  953. border: 1upx #DBDBDB solid;
  954. border-radius: 5upx;
  955. color: #B9B9B9;
  956. font-size: 25upx;
  957. margin-top: 3upx;
  958. }
  959. // 推荐商品样式
  960. .tjgoodlist {
  961. padding: 0 30upx;
  962. .title {
  963. width: 100%;
  964. display: flex;
  965. justify-content: center;
  966. align-items: center;
  967. color: #5FCDA2;
  968. font-size: 30upx;
  969. margin: 20upx 0;
  970. text {
  971. margin: 0 15upx;
  972. }
  973. image {
  974. width: 40upx;
  975. height: 40upx;
  976. }
  977. }
  978. .tj_list {
  979. display: flex;
  980. justify-content: space-around;
  981. padding: 10upx 0;
  982. border-bottom: 1upx #F0F0F0 solid;
  983. height: 260upx;
  984. .tjleft {
  985. width: 50%;
  986. image {
  987. width: 180upx;
  988. height: 180upx;
  989. border-radius: 20upx;
  990. }
  991. }
  992. .tjright {
  993. width: 100%;
  994. padding: 15upx 4%;
  995. display: -webkit-box;
  996. -webkit-box-orient: vertical;
  997. -webkit-line-clamp: 2;
  998. text-align: justify;
  999. overflow: hidden;
  1000. font-size: 28upx;
  1001. color: #747474;
  1002. .tjroot {
  1003. display: flex;
  1004. justify-content: space-between;
  1005. justify-items: center;
  1006. padding-top: 8upx;
  1007. }
  1008. }
  1009. }
  1010. }
  1011. .task-title {
  1012. margin: 30upx;
  1013. .top {
  1014. @include fr(b, c);
  1015. .left {
  1016. @include fr(s, c);
  1017. view {
  1018. @include size(8upx, 36upx);
  1019. border-radius: 4upx;
  1020. margin-right: 10upx;
  1021. background: #50BAFE;
  1022. }
  1023. text {
  1024. @include font(36upx, #3A4E73, bold);
  1025. }
  1026. }
  1027. .right {
  1028. @include fr(s, b);
  1029. text {
  1030. @include font(28upx, #B0B8C7);
  1031. }
  1032. }
  1033. }
  1034. .bottom {
  1035. margin-top: 5upx;
  1036. @include font(24upx, #B0B8C7);
  1037. }
  1038. }
  1039. .task-list {
  1040. padding: 0 30upx;
  1041. .item {
  1042. @include fc();
  1043. @include line(0, 0, 1, 0);
  1044. padding-top: 20upx;
  1045. &:first-child {
  1046. padding-top: 0;
  1047. }
  1048. &:last-child {
  1049. &:after {
  1050. display: none;
  1051. }
  1052. }
  1053. .header {
  1054. @include fr(b, c);
  1055. .left {
  1056. @include fr(s, c);
  1057. .avatar {
  1058. @include size(50upx);
  1059. margin-right: 10upx;
  1060. border-radius: 50%;
  1061. }
  1062. text {
  1063. @include font(24upx, #333);
  1064. }
  1065. }
  1066. .right {
  1067. @include fr(s, c);
  1068. .label {
  1069. @include fr(c, c);
  1070. @include font(22upx, #50BAFE);
  1071. height: 36upx;
  1072. padding: 0 15upx;
  1073. background: #EDF8FF;
  1074. border-radius: 100upx;
  1075. margin-right: 10upx;
  1076. &:last-child {
  1077. margin-right: 0;
  1078. }
  1079. }
  1080. }
  1081. }
  1082. .body {
  1083. padding: 20upx 0;
  1084. padding-left: 5upx;
  1085. @include fr(b, s);
  1086. .left {
  1087. width: 60%;
  1088. @include fc();
  1089. .title {
  1090. width: 100%;
  1091. @include ell();
  1092. @include font(28upx, #666);
  1093. padding-bottom: 10upx;
  1094. }
  1095. .desc {
  1096. width: 100%;
  1097. @include ell(2);
  1098. @include font(22upx, #999);
  1099. }
  1100. }
  1101. .right {
  1102. image {
  1103. @include size(200upx);
  1104. }
  1105. }
  1106. }
  1107. }
  1108. }
  1109. // 猜你喜欢列表
  1110. .goods-list {
  1111. // background-color: #f4f4f4;
  1112. .title {
  1113. width: 100%;
  1114. display: flex;
  1115. justify-content: center;
  1116. align-items: center;
  1117. color: #5FCDA2;
  1118. font-size: 30upx;
  1119. margin: 20upx 0;
  1120. text {
  1121. margin: 0 15upx;
  1122. }
  1123. image {
  1124. width: 40upx;
  1125. height: 40upx;
  1126. }
  1127. }
  1128. .product-list {
  1129. width: 100%;
  1130. padding: 0 4% 3vw 4%;
  1131. display: flex;
  1132. justify-content: space-between;
  1133. flex-wrap: wrap;
  1134. .product {
  1135. width: 48%;
  1136. border-radius: 20upx;
  1137. background-color: #fff;
  1138. margin: 0 0 15upx 0;
  1139. box-shadow: 0upx 5upx 25upx rgba(0, 0, 0, 0.1);
  1140. image {
  1141. width: 100%;
  1142. height: 300upx;
  1143. border-radius: 20upx 20upx 0 0;
  1144. }
  1145. .name {
  1146. width: 100%;
  1147. padding: 10upx 4%;
  1148. display: -webkit-box;
  1149. -webkit-box-orient: vertical;
  1150. -webkit-line-clamp: 2;
  1151. text-align: justify;
  1152. overflow: hidden;
  1153. font-size: 28upx;
  1154. color: #747474;
  1155. }
  1156. .miaos {
  1157. width: 100%;
  1158. margin: 10upx;
  1159. display: -webkit-box;
  1160. -webkit-box-orient: vertical;
  1161. -webkit-line-clamp: 1;
  1162. text-align: justify;
  1163. overflow: hidden;
  1164. font-size: 28upx;
  1165. color: #747474;
  1166. }
  1167. .miaosshow {
  1168. margin: 10upx;
  1169. font-size: 28upx;
  1170. color: #747474;
  1171. }
  1172. .info {
  1173. display: flex;
  1174. justify-content: space-between;
  1175. align-items: flex-end;
  1176. width: 92%;
  1177. padding: 10upx 4% 10upx 4%;
  1178. .price {
  1179. color: #e65339;
  1180. font-size: 30upx;
  1181. font-weight: 600;
  1182. }
  1183. .slogan {
  1184. color: #807c87;
  1185. font-size: 24upx;
  1186. }
  1187. }
  1188. .add {
  1189. image {
  1190. width: 43upx;
  1191. height: 40upx;
  1192. padding: 7upx;
  1193. }
  1194. }
  1195. }
  1196. }
  1197. }
  1198. .nosell {
  1199. display: flex;
  1200. justify-content: flex-end;
  1201. text {
  1202. position: relative;
  1203. right: 5upx;
  1204. padding: 5upx;
  1205. background-color: #EAEAEA;
  1206. color: white;
  1207. font-size: 28upx !important;
  1208. }
  1209. }
  1210. .number {
  1211. display: flex;
  1212. justify-content: flex-end;
  1213. margin-right: 30upx;
  1214. margin-bottom: 10upx;
  1215. .input {
  1216. width: 70upx;
  1217. height: 45upx;
  1218. margin: 0 10upx;
  1219. // background-color: #f3f3f3;
  1220. border-bottom: 1upx #ADADAD solid;
  1221. input {
  1222. width: 60upx;
  1223. height: 60upx;
  1224. display: flex;
  1225. justify-content: center;
  1226. align-items: center;
  1227. text-align: center;
  1228. font-size: 26upx;
  1229. }
  1230. }
  1231. .sub,
  1232. .add {
  1233. width: 45upx;
  1234. height: 45upx;
  1235. border-radius: 5upx;
  1236. }
  1237. .jia {
  1238. display: flex;
  1239. width: 45upx;
  1240. height: 45upx;
  1241. justify-content: center;
  1242. justify-items: center;
  1243. align-items: center;
  1244. background-color: #41A863;
  1245. color: #fff;
  1246. border-radius: 50%;
  1247. image {
  1248. width: 40upx;
  1249. height: 40upx;
  1250. padding: 7upx;
  1251. }
  1252. }
  1253. .jian {
  1254. display: flex;
  1255. width: 45upx;
  1256. height: 45upx;
  1257. justify-content: center;
  1258. justify-items: center;
  1259. align-items: center;
  1260. background-color: #41A863;
  1261. color: #fff;
  1262. border-radius: 50%;
  1263. padding-bottom: 10upx;
  1264. }
  1265. }
  1266. //收藏样式
  1267. .p-b-btn {
  1268. .yticon {
  1269. font-size: 40upx;
  1270. line-height: 48upx;
  1271. color: $font-color-light;
  1272. }
  1273. &.active,
  1274. &.active .yticon {
  1275. color: $uni-color-primary;
  1276. }
  1277. .icon-fenxiang2 {
  1278. font-size: 42upx;
  1279. transform: translateY(-2upx);
  1280. }
  1281. .icon-shoucang {
  1282. font-size: 50upx;
  1283. }
  1284. }
  1285. </style>