123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // subPackagesF/pages/seckillDetail/seckillDetail.js
- import {
- get,
- } from '../../../utils/http'
- var WxParse = require('../../../components/local/wxParse/wxParse.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- store_id:'', //店铺ID
- storeName:'',//店铺名称
- goods_id:'',//商品ID
- seckillDetail:[],//秒杀产品详情
- seckill_id:"",//秒杀ID
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options);
- this.setData({
- goods_id:options.goods_id,
- store_id:wx.getStorageSync('store_id'),
- seckill_id:options.seckill_id
- })
- // 获取店铺信息
- this.getStoreInfo()
- // 获取秒杀产品详情
- this.getSeckillDetail()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 去除富文本图片默认样式
- */
- removeCss(content) {
- let reg = /(style|class)="[^"]+"/gi
- let img = /<img[^>]+>/gi
- let res
- if (img.test(content)) {
- res = content.match(img)
- for (let i = 0; i < res.length; i++) {
- content = content.replace(res[i], res[i].replace(reg, ''))
- }
- }
- return content.replace(/\<img/gi, '<img class="richImg" ')
- },
- // 获取秒杀商品详情
- getSeckillDetail(){
- get('v2/api/spike/info',{
- id:this.data.goods_id,
- seckill_id:this.data.seckill_id
- },(res=>{
- if(res.code==200){
- let content = this.removeCss(res.data.content)
- res.data.content = this.removeCss(res.data.content)
- WxParse.wxParse('article', 'html', content, this, 5)
- res.data.banner_urls = res.data.banner_urls.split(',');
- this.setData({
- seckillDetail:res.data
- })
- }
- }))
- },
- // 获取店铺信息
- getStoreInfo(){
- get('api/store/info',{store_id:this.data.store_id},(res=>{
- if(res.code==200){
- this.setData({
- storeName:res.data.store_name
- })
- }
- }))
- },
- // 跳转到秒杀产品订单
- goSeckillOrder(){
- wx.navigateTo({
- url: `/subPackagesF/pages/seckillOrder/seckillOrder?goods_id=${this.data.goods_id}&&store_id=${this.data.store_id}&seckill_id=${this.data.seckill_id}`,
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|