| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <template>
- <view class="">
- <view class="page">
- <navBar :backType="navBarTitle" :title="navBarTitle?navBarTitle:'详情'" :back="true" color="black"
- background="white" />
- <view class="topImg">
- <u-swiper type='img' radius="0rpx 0rpx 0rpx 40rpx" :list="bannerList" keyName="image" indicator
- indicatorMode="line" :autoplay="true" height="1124rpx" imgMode="heightFix" circular
- @change="e => currentNum = e.current">
- <view slot="indicator">
- </view>
- </u-swiper>
- <view class="indicatorBox1">
- <view class="indicator1">
- <view class="indicator1__dot1" style="" v-for="(item, index) in bannerList" :key="index"
- :class="[index === currentNum ?'indicator1__dot1--active1':'']">
- </view>
- </view>
- </view>
- </view>
- <view class="cen">
- <image class="water" src="/static/index/water.png" mode=""></image>
- <image class="halfC" src="/static/index/halfCircle_275.png" mode=""></image>
- <image class="love" :src="lovePic" mode="" @click="handleCol"></image>
- <view class="txtBox">
- <view class="left">
- {{content.name}}
- </view>
- <view class="right">
- {{totalCount}}人已收藏
- </view>
- </view>
- </view>
- <view class="parmasBox" v-for="(item,index) in parmsList" v-if="navBarTitle" :key="index">
- <view class="con">
- <view class="title">
- {{item.title}}
- </view>
- <view class="list">
- <view class="item" v-for="(item1,index1) in item.list" :class="[index1==ids[index]?'act':'']"
- @click="">
- {{item1.data}}
- </view>
- </view>
- </view>
- </view>
- <view class="parmasBox" v-for="(item,index) in parmsList" :key="index" v-if="!navBarTitle">
- <view class="con">
- <view class="title">
- {{item.title}}
- </view>
- <view class="list">
- <view class="item" v-for="(item1,index1) in item.list" :class="[item1.isSelect?'act':'']"
- @click="handleSel(item.list,index1,item[index],index)" :key="index1">
- {{item1.data}}
- </view>
- </view>
- </view>
- </view>
- <view class="parmasBox" style="border-bottom: none;">
- <view class="con" @click="handleOpenOrClose(1)">
- <view class="title1">
- <view class="txt">
- 商品描述
- </view>
- <image class="add" :src="addOrLessIcon1" mode="" :style="{height:addOrLessIcon1=='/static/index/shortLine.png'
- ?'2rpx':'22rpx'}"></image>
- </view>
- <view class="des" v-if="show1">
- <u-parse :content="content1"></u-parse>
- </view>
- </view>
- </view>
- </view>
- <view class="bot" v-if="!navBarTitle">
- <view class="left">
- <view class="price">
- ¥{{totalPrice.toFixed(2)}}
- </view>
- <image src="/static/index/arrDown.png" mode=""></image>
- </view>
- <button open-type="share" class="right">
- 分享
- </button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getMyCollectDetailReq,
- } from '@/api/my/index.js'
- import {
- addCollReq,
- cancelCollReq,
- getGoodsPriceReq,
- postOrderReq,
- } from '@/api/test/index.js'
- export default {
- components: {
- },
- data() {
- return {
- picUrl: this.$picUrl,
- picBase: this.$picBase,
- currIndex: 0,
- currIndex1: 0,
- currIndex2: 0,
- show1: false,
- addOrLessIcon1: '/static/index/add.png',
- lovePic: '/static/mall/love.png',
- content: null,
- currentNum: 0,
- bannerList: [],
- totalCount: 0,
- content1: '',
- parmsList: [],
- checkFullSel1: [],
- checkFullSel: 0,
- totalPrice: 0,
- parmsObj: {},
- navBarTitle: '',
- ids: [],
- cutdownRatio: 1
- }
- },
- async onLoad(o) {
- // o.id = 1
- if (o.id) {
- this.ids = JSON.parse(o.ids)
- this.navBarTitle = '首页'
- let res = await getMyCollectDetailReq({
- id: o.id
- })
- if (res.code == 0) {
- console.log('我的收藏详情', res);
- this.content = res.data
- this.bannerList = this.content.images
- this.totalCount = this.content.collect_total_count
- if (this.content.isCollect) {
- this.lovePic = "/static/mall/love.png"
- } else {
- this.lovePic = "/static/mall/no_love.png"
- }
- this.content1 = this.content.content
- this.parmsList = this.content.skuParams
- this.parmsList.forEach((item, index) => {
- this.parmsObj[item.title] = null
- this.checkFullSel1.push(0)
- })
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- } else {
- let res = await getMyCollectDetailReq({
- id: getApp().Sid
- })
- if (res.code == 0) {
- console.log('我的收藏详情', res);
- this.content = res.data
- this.bannerList = this.content.images
- this.totalCount = this.content.collect_total_count
- if (this.content.isCollect) {
- this.lovePic = "/static/mall/love.png"
- } else {
- this.lovePic = "/static/mall/no_love.png"
- }
- this.content1 = this.content.content
- this.parmsList = this.content.skuParams
- this.parmsList.forEach((item, index) => {
- this.parmsObj[item.title] = null
- this.checkFullSel1.push(0)
- })
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- }
- },
- onShow() {
- this.cutdownRatio = this.$getCutDown()
- },
- onShareAppMessage(params) {
- let ids = []
- this.parmsList.forEach((item, index) => {
- item.list.forEach((item1, index1) => {
- if (item1.isSelect) {
- ids.push(index1)
- }
- })
- })
- console.log('选中的二维iindex数组', ids);
- if (params.from === 'button' || params.from === 'menu') {
- return {
- title: this.content.name,
- imageUrl: this.$picBase + this.content.cover,
- path: '/pages/my/collectDetail/index?id=' + this.content.id + '&ids=' + JSON.stringify(ids),
- mpId: this.$appId,
- type: this.$shareType,
- }
- }
- },
- watch: {
- checkFullSel: {
- async handler(n, o) {
- let res = this.checkFullSel1.every((item, index) => {
- return item == 1
- })
- if (res) {
- let parms = []
- Object.keys(this.parmsObj).forEach((item4, index8) => {
- parms.push(this.parmsObj[item4])
- })
- console.log(parms);
- let res = await getGoodsPriceReq({
- goods_id: this.content.id,
- stock: parms
- })
- if (res.code == 0) {
- console.log(res);
- this.totalPrice = res.data * this.cutdownRatio
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- }
- },
- }
- },
- methods: {
- handleSel(item, index1, outer, pindex) {
- console.log('this.checkFullSel1', this.checkFullSel1);
- this.checkFullSel = Date.now()
- item.forEach(async (item2, index) => {
- item2.isSelect = 0
- if (index == index1) {
- item[index1].isSelect = 1
- this.parmsObj[item[index1].title] = {
- classify: item[index1].title,
- value: item[index1].data
- }
- this.checkFullSel1[pindex] = 1
- }
- })
- },
- async handleCol() {
- if (this.lovePic == "/static/mall/no_love.png") {
- let res = await addCollReq({
- id: this.content.id,
- })
- if (res.code == 0) {
- console.log('添加收藏返回值: ', res);
- this.$toast('收藏成功')
- this.totalCount += 1
- if (this.lovePic == "/static/mall/love.png") {
- this.lovePic = "/static/mall/no_love.png"
- } else {
- this.lovePic = "/static/mall/love.png"
- }
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- } else {
- let res = await cancelCollReq({
- id: this.content.id,
- })
- if (res.code == 0) {
- console.log('取消收藏返回值: ', res);
- this.$toast('取消收藏成功')
- this.totalCount -= 1
- if (this.lovePic == "/static/mall/love.png") {
- this.lovePic = "/static/mall/no_love.png"
- } else {
- this.lovePic = "/static/mall/love.png"
- }
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- }
- },
- handleOpenOrClose(i) {
- if (this['addOrLessIcon' + i] == '/static/index/shortLine.png') {
- this['addOrLessIcon' + i] = '/static/index/add.png'
- this['show' + i] = false
- } else if (this['addOrLessIcon' + i] == '/static/index/add.png') {
- this['addOrLessIcon' + i] = '/static/index/shortLine.png'
- this['show' + i] = true
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "./index.scss";
- </style>
|