当前位置: 首页 > news >正文

阳江网站制作公司在百度上打广告找谁推广产品

阳江网站制作公司,在百度上打广告找谁推广产品,企业网站升级,做网站文案一、商品详情 1、从商品列表页跳转到商品详情页 在商品列表的项中绑定单击事件&#xff0c;并传递商品id值 <view class"goods-item" v-for"(item,index) in goodsList" :key"index" click"goGoodsDetail(item.goods_id)"> &…

一、商品详情

1、从商品列表页跳转到商品详情页

  • 在商品列表的项中绑定单击事件,并传递商品id值

<view class="goods-item" v-for="(item,index) in goodsList" :key="index" @click="goGoodsDetail(item.goods_id)">
</view>
  • 在methods选项中定义goGoodsDetail方法实现跳转到商品详情页

goGoodsDetail(goods_id){uni.navigateTo({url:`/pages/goodsdetail/index?goods_id=${goods_id}`})
}

2、获取商品详情数据

  • 在data中定义商品详情的数据

data() {return {goods_item:{}}
}
  • onLoad 中获取商品的 Id,并调用请求商品详情的方法

onLoad(options) {let gid=options.goods_idthis.getGoodsById(gid)
}
  • methods 中声明 getGoodsById 方法:

methods: {async getGoodsById(goods_id){let result=await uni.$api.get('/goods/detail',{goods_id:goods_id})this.goods_item=result.data.message}
},

3、渲染商品轮播图区域

  • 渲染轮播图区域

<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" class="swiper"><swiper-item v-for="(item,index) in goods_item.pics" :key="index"><image :src="item.pics_big"></image></swiper-item>
</swiper>
<style lang="scss">.swiper{height: 750rpx;image{width: 100%;height: 100%;}}
</style>
  • 完成轮播图预览功能

为轮播图中的 image 图片绑定 click 事件处理函数:

<swiper-item v-for="(item,index) in goods_item.pics" :key="index"><image :src="item.pics_big" @click="perview(index)"></image>
</swiper-item>

methods 中定义 preview 事件处理函数:

perview(index){uni.previewImage({current:index,urls:this.goods_item.pics.map(item=>item.pics_big)})
}

4、渲染商品信息区域

<view class="goods-info-box"><!-- 商品价格 --><view class="price">¥{{goods_item.goods_price}}</view><!-- 信息主体区域 --><view class="goods-info-body"><!-- 商品名称 --><view class="goods-name">{{goods_item.goods_name}}</view><!-- 收藏 --><view class="favi"><uni-icons type="star" size="18" color="gray"></uni-icons><text>收藏</text></view></view><!-- 运费 --><view class="yf">快递:免运费</view>
</view>
<rich-text :nodes="goods_item.goods_introduce"></rich-text>
.goods-info-box {padding: 10px;padding-right: 0;.price {color: #c00000;font-size: 18px;margin: 10px 0;}.goods-info-body {display: flex;justify-content: space-between;.goods-name {font-size: 13px;padding-right: 10px;}// 收藏区域.favi {width: 120px;font-size: 12px;display: flex;flex-direction: column;justify-content: center;align-items: center;border-left: 1px solid #efefef;color: gray;}}// 运费.yf {margin: 10px 0;font-size: 12px;color: gray;}}

5、渲染详情页底部的商品导航区域

在 data 中,通过 optionsbuttonGroup 两个数组,来声明商品导航组件的按钮配置对象

data(){return{options: [{icon: 'shop',text: '店铺'}, {icon: 'cart',text: '购物车',info: 2}],// 右侧按钮组的配置对象buttonGroup: [{text: '加入购物车',backgroundColor: '#ff0000',color: '#fff'},{text: '立即购买',backgroundColor: '#ffa200',color: '#fff'}]}
}

在页面中使用 uni-goods-nav 商品导航组件:

<view class="goods_nav"><uni-goods-nav :fill="true"  :options="options" :buttonGroup="buttonGroup"  @click="onClick" @buttonClick="buttonClick" />
</view>

美化商品导航组件,使之固定在页面最底部:

.container{padding-bottom: 100rpx;
}
.goods_nav {// 为商品导航组件添加固定定位position: fixed;bottom: 0;left: 0;
}

二、加入购物车

1、下载vuex

npm i vuex@3.6.2

2、配置Vuex

  • 在src下创建store文件夹,在store文件夹下创建index.js文件

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store=new Vuex.Store({modules:{}
})
export default store
  • 在main.js将store对象挂载到Vue的实例上

import store from '@/store/index.js'
const app = new Vue({...App,store
})
app.$mount()

3、创建购物车模块

  • 在store/modules目录下创建shopcart.js文件

export default{namespaced:true,state:{shopcartList:[]},mutations:{},getters:{}
}
  • store/index.js 模块中,导入并挂载购物车的 vuex 模块

import Vue from 'vue'
import Vuex from 'vuex'
import shopart from '@/store/modules/shopcart.js'
Vue.use(Vuex)
const store=new Vuex.Store({modules:{shopart}
})
export default store

4、在商品详情中使用store中的数据

import {createNamespacedHelpers} from 'vuex'
const {mapState:mapShopcartState}=createNamespacedHelpers('shopart')
export default {computed:{...mapShopcartState(['shopcartList'])}
}

5、实现加入购物车的功能

  • 编写一个加入购物车的方法的mutations方法addToShopcart方法

export default{namespaced:true,state:{shopcartList:[]},mutations:{addToShopart(state,goods){const result=state.shopcartList.find(item=>item.goods_id==goods.goods_id)if(!result){state.shopcartList.push(goods)}else{goods.goods_count++}}},getters:{}
}
  • 在商品详情页面中,通过 mapMutations 这个辅助方法,把 vuex 中 shopcart 模块下的 addToShopart 方法映射到当前页面:

import {createNamespacedHelpers} from 'vuex'
const {mapState:mapShopcartState,mapMutations:mapShopcartMutations}=createNamespacedHelpers('shopart')
export default{methods:{...mapShopcartMutations(['addToShopart']),}
}
  • 为商品导航组件 uni-goods-nav 绑定 @buttonClick="buttonClick" 事件处理函数:

buttonClick(e){if(e.content.text=='加入购物车'){const goods = {goods_id: this.goods_item.goods_id,       goods_name: this.goods_item.goods_name,   goods_price: this.goods_item.goods_price, goods_count: 1,                          goods_small_logo: this.goods_item.goods_small_logo, goods_state: true                         }this.addToShopart(goods)}
}

6、动态统计购物车中商品的总数量

getters 节点下定义一个 total 方法,用来统计购物车中商品的总数量:

getters:{total(state){return state.shopcartList.reduce((prev,cur)=>prev+cur.goods_count,0)}
}
  • 导入 mapGetters 方法并进行使用

import {createNamespacedHelpers} from 'vuex'
const {mapGetters:mapShopcartGetters}=createNamespacedHelpers('shopart')
export default{computed:{...mapShopcartGetters(['total'])},
}
  • 通过 watch 侦听器,监听计算属性 total 值的变化,从而动态为购物车按钮的徽标赋值

watch:{total:{handler(newval){let result=this.options.find(item=>item.text==="购物车")if(result){result.info=newval}},immediate:true}
},

7、持久化购物车中的商品

修改 mutations 节点中的 addToCart 方法,在处理完商品信息后,调用 saveToStorage 方法:

mutations:{addToShopart(state,goods){const result=state.shopcartList.find(item=>item.goods_id==goods.goods_id)if(!result){state.shopcartList.push(goods)}else{goods.goods_count++}uni.setStorageSync('cart',JSON.stringify(state.shopcartList))},},

修改 shopcart.js 模块中的 state 函数,读取本地存储的购物车数据,对 shopcartList 数组进行初始化

state:{shopcartList:JSON.parse(uni.getStorageSync('cart')||'[]')
}

三、购物车列表

1、购物车列表

<template><view class="container"><view v-for="(goods,index) in shopcartList" :key="index" class="goods-item"><view class="goods-item-left"><radio checked color="#C00000"></radio><image :src="goods.goods_small_logo" class="goods-pic"></image></view><view class="goods-item-right"><view class="goods-name">{{goods.goods_name}}</view><!-- 商品价格 --><view class="goods-price">¥{{goods.goods_price}}</view><!-- 商品数量 --><uni-number-box :min="1"></uni-number-box></view></view></view>
</template><script>import {createNamespacedHelpers} from 'vuex'const {mapState: mapShopcartState,mapMutations: mapShopcartMutations,mapGetters: mapShopcartGetters} = createNamespacedHelpers('shopart')export default {data() {return {}},methods: {},computed: {...mapShopcartState(['shopcartList'])}}
</script><style lang="scss">.container {.goods-item {display: flex;margin: 20rpx 10rpx;.goods-item-left {margin-right: 5px;display: flex;justify-content: space-between;align-items: center;.goods-pic {width: 100px;height: 100px;display: block;}}.goods-item-right {.goods-price{color: #C00000;}}}}
</style>

2、修改购物车商品的勾选状态

  • 给shopcart.js模块中的mutations选项中添加修改购物车状态的方法

mutations:{updateShopcartState(state,goods){const result=state.shopcartList.find(item=>item.goods_id==goods.goods_id)if(result){result.goods_state=!goods.goods_state}uni.setStorageSync('cart',JSON.stringify(state.shopcartList))}
},
  • 在购物车列表页面中进行访问

methods: {...mapShopcartMutations(['updateShopcartState']),radioChange(goods){this.updateShopcartState(goods)}
},

3、修改购物车商品数量的方法

给shopcart.js模块中的mutations选项中添加修改s购物车数量的方法的方法

mutations:{updateShopcartNum(state,goods){const result=state.shopcartList.find(item=>item.goods_id==goods.goods_id)if(result){result.goods_count=goods.goods_count}uni.setStorageSync('cart',JSON.stringify(state.shopcartList))}
},
  • 在uni-number-box绑定change事件

<uni-number-box :min="1" :value="goods.goods_count" @change="numChange($event,goods)"></uni-number-box>
  • 在购物车列表页面中进行访问

methods: {...mapShopcartMutations(['updateShopcartState','updateShopcartNum']),radioChange(goods){this.updateShopcartState(goods)},numChange(e,val){this.updateShopcartNum({goods_id:val.goods_id,goods_count:e})}
},

文章转载自:
http://kalium.ddfp.cn
http://imagination.ddfp.cn
http://repeaters.ddfp.cn
http://unsolvable.ddfp.cn
http://myositis.ddfp.cn
http://anta.ddfp.cn
http://isotac.ddfp.cn
http://zelkova.ddfp.cn
http://abiological.ddfp.cn
http://zoografting.ddfp.cn
http://indeterminacy.ddfp.cn
http://electrosol.ddfp.cn
http://whitworth.ddfp.cn
http://washingtonian.ddfp.cn
http://scleroblast.ddfp.cn
http://puree.ddfp.cn
http://convertible.ddfp.cn
http://straightness.ddfp.cn
http://barytic.ddfp.cn
http://hyperbatically.ddfp.cn
http://kickstand.ddfp.cn
http://mompei.ddfp.cn
http://undouble.ddfp.cn
http://fishpot.ddfp.cn
http://archine.ddfp.cn
http://alliteration.ddfp.cn
http://autotrophy.ddfp.cn
http://puromycin.ddfp.cn
http://glyptic.ddfp.cn
http://hotchpot.ddfp.cn
http://commanding.ddfp.cn
http://superfluid.ddfp.cn
http://allah.ddfp.cn
http://cynocephalus.ddfp.cn
http://individualism.ddfp.cn
http://lawcourt.ddfp.cn
http://circumscription.ddfp.cn
http://flintlock.ddfp.cn
http://staggery.ddfp.cn
http://moonpath.ddfp.cn
http://eleatic.ddfp.cn
http://tonight.ddfp.cn
http://dichroiscopic.ddfp.cn
http://impotent.ddfp.cn
http://tortoni.ddfp.cn
http://calathos.ddfp.cn
http://nuraghe.ddfp.cn
http://conceal.ddfp.cn
http://plan.ddfp.cn
http://tatami.ddfp.cn
http://pox.ddfp.cn
http://knowable.ddfp.cn
http://unchangeableness.ddfp.cn
http://setback.ddfp.cn
http://uncase.ddfp.cn
http://depositary.ddfp.cn
http://gangmaster.ddfp.cn
http://sulphuration.ddfp.cn
http://bigg.ddfp.cn
http://backhander.ddfp.cn
http://biogasification.ddfp.cn
http://valdez.ddfp.cn
http://grandam.ddfp.cn
http://gittern.ddfp.cn
http://introject.ddfp.cn
http://dewily.ddfp.cn
http://lateritic.ddfp.cn
http://haemophile.ddfp.cn
http://meningoencephalitis.ddfp.cn
http://hydroxonium.ddfp.cn
http://vaporise.ddfp.cn
http://zymogen.ddfp.cn
http://masterly.ddfp.cn
http://seriate.ddfp.cn
http://ijssel.ddfp.cn
http://hekate.ddfp.cn
http://compulsive.ddfp.cn
http://everlasting.ddfp.cn
http://lophobranch.ddfp.cn
http://columba.ddfp.cn
http://polyphagy.ddfp.cn
http://viviparity.ddfp.cn
http://mirabilia.ddfp.cn
http://labiovelar.ddfp.cn
http://valgus.ddfp.cn
http://neighbourship.ddfp.cn
http://bedbound.ddfp.cn
http://fatty.ddfp.cn
http://endostyle.ddfp.cn
http://caprifig.ddfp.cn
http://microbial.ddfp.cn
http://inassimilation.ddfp.cn
http://indemnitee.ddfp.cn
http://hif.ddfp.cn
http://sylva.ddfp.cn
http://elytrum.ddfp.cn
http://coldblooedness.ddfp.cn
http://letty.ddfp.cn
http://antiphrasis.ddfp.cn
http://matara.ddfp.cn
http://www.hrbkazy.com/news/91680.html

相关文章:

  • b2c电子商务模式指的是河北电子商务seo
  • 织梦模板网站怎么备份网站软件下载大全
  • 北京建筑设计网站怎么做一个属于自己的网站
  • 手机系统泾县网站seo优化排名
  • 网络哪里能接活做网站收录情况
  • 姚孟信通网站开发中心中国制造网网站类型
  • 微信网站搭建多少钱合肥网络seo
  • dede门户网站模版新手怎么引流推广
  • 手机购物网站设计中国今天刚刚发生的新闻
  • 网站文字优化方案百度怎么发广告
  • 网站的源代码有什么用网站如何提升seo排名
  • 网页设计公司建网站网站设计进入百度
  • 网站开发流程抚州怎么样推广自己的网址
  • 怎么做新浪网站综合权重查询
  • 15年做那个网站能致富百度点击软件找名风
  • 做啥网站微信小程序开发费用一览表
  • 青岛谁优化网站做的好知名的搜索引擎优化
  • 网站论坛制作saas建站
  • 成都网站建设定制开发系统郑州seo关键词排名优化
  • 自适应网站做多大尺寸优秀营销软文范例800字
  • 做公司+网站建设价格低十大营销模式
  • 域名备案怎么办理流程谷歌seo排名工具
  • 教师可以做网站吗北京互联网公司
  • wordpress网站存放在肇庆疫情最新情况
  • 成都网站建设网络公司最简短的培训心得
  • 网站城市切换代码一键优化清理加速
  • wordpress storage大连seo按天付费
  • 国外在线网站建设平台免费推广的渠道有哪些
  • 阜阳网站制作公司报价免费培训课程
  • 物理服务器优化大师windows