提交 383bda99 编写于 作者: api工厂's avatar api工厂

细节优化

上级 0a544d62
......@@ -65,7 +65,7 @@ App({
wx.hideToast()
}
})
WXAPI.queryConfigBatch('mallName,WITHDRAW_MIN,ALLOW_SELF_COLLECTION,order_hx_uids,subscribe_ids,share_profile,adminUserIds,goodsDetailSkuShowType,shopMod,needIdCheck,balance_pay_pwd,shipping_address_gps,shipping_address_region_level,shopping_cart_vop_open,show_wx_quanzi,cps_open,recycle_open').then(res => {
WXAPI.queryConfigBatch('mallName,WITHDRAW_MIN,ALLOW_SELF_COLLECTION,order_hx_uids,subscribe_ids,share_profile,adminUserIds,goodsDetailSkuShowType,shopMod,needIdCheck,balance_pay_pwd,shipping_address_gps,shipping_address_region_level,shopping_cart_vop_open,show_wx_quanzi,cps_open,recycle_open,categoryMod').then(res => {
if (res.code == 0) {
res.data.forEach(config => {
wx.setStorageSync(config.key, config.value);
......
......@@ -11,13 +11,11 @@
"pages/goods/fav",
"pages/goods-details/index",
"pages/goods-details/vop",
"pages/goods-details/cps-jd",
"pages/shop-cart/index",
"pages/to-pay-order/index",
"pages/select-address/index",
"pages/address-add/index",
"pages/order-list/index",
"pages/order-list/cps",
"pages/order-details/index",
"pages/order-details/scan-result",
"pages/order/refundApply",
......@@ -70,6 +68,15 @@
"pages/live-client/list",
"pages/live-client/client"
]
},
{
"root": "packageCps",
"name": "packageCps",
"pages": [
"pages/goods-details/cps-jd",
"pages/goods-details/cps-pdd",
"pages/order-list/cps"
]
}
],
"window": {
......@@ -159,7 +166,8 @@
"van-grid-item": "@vant/weapp/grid-item/index",
"van-image": "@vant/weapp/image/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index"
"van-tabs": "@vant/weapp/tabs/index",
"van-overlay": "@vant/weapp/overlay/index"
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
......@@ -95,7 +95,7 @@ module.exports =
/* eslint-disable */
// 小程序开发api接口工具包,https://github.com/gooking/wxapi
var API_BASE_URL = 'https://api.it120.cc';
// var API_BASE_URL = 'http://192.168.31.76:8081';
// var API_BASE_URL = 'http://127.0.0.1:8081';
var subDomain = '-';
var merchantId = '0';
......@@ -1633,6 +1633,21 @@ module.exports = {
cpsJdOrderDetail: (token, id) => {
return request('/cpsJdOrder/detail', true, 'get', { token, id })
},
cpsPddBeian: token => {
return request('/cpsPddGoods/beian', true, 'get', { token })
},
cpsPddGoodsDetail: data => {
return request('/cpsPddGoods/detail', true, 'get', data)
},
cpsPddGoodsShotUrl: (token, goodsSign) => {
return request('/cpsPddGoods/shotUrl', true, 'get', { token, goodsSign })
},
cpsPddOrders: data => {
return request('/cpsPddOrder/list', true, 'post', data)
},
cpsPddOrderDetail: (token, id) => {
return request('/cpsPddOrder/detail', true, 'get', { token, id })
},
recycleOrders: data => {
return request('/recycleOrder/list', true, 'post', data)
},
......
const WXAPI = require('apifm-wxapi')
const app = getApp();
const CONFIG = require('../../config.js')
const TOOLS = require('../../utils/tools.js')
const AUTH = require('../../utils/auth')
const CONFIG = require('../../../config.js')
const TOOLS = require('../../../utils/tools.js')
const AUTH = require('../../../utils/auth')
const SelectSizePrefix = "选择:"
import Poster from 'wxa-plugin-canvas/poster/poster'
......@@ -171,7 +171,7 @@ Page({
})
} else {
const extJsonStr = {
wxaurl: `/pages/goods-details/cps-jd?id=${this.data.goodsId}`,
wxaurl: `/packageCps/pages/goods-details/cps-jd?id=${this.data.goodsId}`,
skuId: this.data.goodsId,
pic: this.data.goodsDetail.basicInfo.pic,
name: this.data.goodsDetail.basicInfo.name
......@@ -414,7 +414,7 @@ Page({
onShareAppMessage() {
let _data = {
title: this.data.goodsDetail.basicInfo.name,
path: '/pages/goods-details/cps-jd?id=' + this.data.goodsId + '&inviter_id=' + wx.getStorageSync('uid'),
path: '/packageCps/pages/goods-details/cps-jd?id=' + this.data.goodsId + '&inviter_id=' + wx.getStorageSync('uid'),
success: function(res) {
// 转发成功
},
......@@ -565,7 +565,7 @@ Page({
const _this = this
const qrcodeRes = await WXAPI.wxaQrcode({
scene: _this.data.goodsId + ',' + wx.getStorageSync('uid'),
page: 'pages/goods-details/cps-jd',
page: '/packageCps/pages/goods-details/cps-jd',
is_hyaline: true,
autoColor: true,
expireHours: 1
......@@ -705,7 +705,7 @@ Page({
"image_list":[
this.data.goodsDetail.basicInfo.pic
],
"src_mini_program_path": '/pages/goods-details/cps-jd?id=' + this.data.goodsDetail.basicInfo.id
"src_mini_program_path": '/packageCps/pages/goods-details/cps-jd?id=' + this.data.goodsDetail.basicInfo.id
}
})
},
......
......@@ -253,7 +253,7 @@
<van-goods-action wx:if="{{!curGoodsKanjia}}">
<van-goods-action-icon icon="chat-o" text="客服" open-type="contact"
send-message-title="{{goodsDetail.basicInfo.name}}" send-message-img="{{goodsDetail.basicInfo.pic}}"
send-message-path="/pages/goods-details/cps-jd?id={{goodsDetail.basicInfo.id}}" show-message-card="{{ true }}" />
send-message-path="/packageCps/pages/goods-details/cps-jd?id={{goodsDetail.basicInfo.id}}" show-message-card="{{ true }}" />
<van-goods-action-icon icon="{{faved?'like':'like-o'}}" text="收藏" bind:click="addFav" />
<van-goods-action-button text="立即购买" data-shopType="{{shopType}}"
bind:click="tobuy" />
......
const WXAPI = require('apifm-wxapi')
const AUTH = require('../../../utils/auth')
import Poster from 'wxa-plugin-canvas/poster/poster'
Page({
data: {
beianPass: 0, // 0 未判断,1 未备案, 2 已备案
},
onLoad(e) {
// e.id = 819066
// 读取分享链接中的邀请人编号
if (e && e.inviter_id) {
wx.setStorageSync('referrer', e.inviter_id)
}
// 读取小程序码中的邀请人编号
if (e && e.scene) {
const scene = decodeURIComponent(e.scene) // 处理扫码进商品详情页面的逻辑
if (scene && scene.split(',').length >= 2) {
e.id = scene.split(',')[0]
wx.setStorageSync('referrer', scene.split(',')[1])
}
}
this.data.goodsId = e.id
this.setData({
show_wx_quanzi: wx.getStorageSync('show_wx_quanzi')
})
},
async cpsPddBeian() {
if (this.data.beianPass == 2) {
return
}
await AUTH.authorize()
AUTH.bindSeller()
const token = wx.getStorageSync('token')
const res = await WXAPI.cpsPddBeian(token)
if (res.code == 10000) {
wx.setNavigationBarTitle({
title: '商品详情',
})
this.setData({
beianPass: 2
})
this.goodsDetail()
return
}
if (res.code == 0) {
wx.setNavigationBarTitle({
title: '认证页',
})
this.setData({
beianPass: 1,
beianData: res.data
})
} else {
wx.showModal({
title: '错误',
content: res.msg,
showCancel: false,
success: res => {
wx.navigateBack()
}
})
}
},
goBeian() {
wx.navigateToMiniProgram({
appId: this.data.beianData.we_app_info.app_id,
path: this.data.beianData.we_app_info.page_path
})
},
async goodsDetail() {
const token = wx.getStorageSync('token')
const res = await WXAPI.goodsDetail(this.data.goodsId, token ? token : '')
if (res.code == 0) {
this.setData({
goodsDetail: res.data,
})
this.cpsPddGoodsDetail(res.data.basicInfo.yyId)
}
},
async cpsPddGoodsDetail(skuId) {
const token = wx.getStorageSync('token')
const res = await WXAPI.cpsPddGoodsDetail({
token,
goodsSign: this.data.goodsDetail.basicInfo.yyIdStr
})
if (res.code == 0) {
this.setData({
cpsPddGoodsDetail: res.data
})
}
},
onShow (){
AUTH.checkHasLogined().then(isLogined => {
if (isLogined) {
this.cpsPddBeian()
this.goodsFavCheck()
}
})
},
async goodsFavCheck() {
const res = await WXAPI.goodsFavCheck(wx.getStorageSync('token'), this.data.goodsId)
if (res.code == 0) {
this.setData({
faved: true
})
} else {
this.setData({
faved: false
})
}
},
async addFav(){
AUTH.checkHasLogined().then(isLogined => {
this.setData({
wxlogin: isLogined
})
if (isLogined) {
if (this.data.faved) {
// 取消收藏
WXAPI.goodsFavDeleteV2({
token: wx.getStorageSync('token'),
goodsId: this.data.goodsId,
type: 1
}).then(res => {
this.goodsFavCheck()
})
} else {
const extJsonStr = {
wxaurl: `/packageCps/pages/goods-details/cps-pdd?id=${this.data.goodsId}`,
skuId: this.data.goodsId,
pic: this.data.goodsDetail.basicInfo.pic,
name: this.data.goodsDetail.basicInfo.name
}
// 加入收藏
WXAPI.goodsFavAdd({
token: wx.getStorageSync('token'),
goodsId: this.data.goodsId,
type: 1,
extJsonStr: JSON.stringify(extJsonStr)
}).then(res => {
this.goodsFavCheck()
})
}
}
})
},
goShopCar: function() {
wx.reLaunch({
url: "/pages/shop-cart/index"
});
},
toAddShopCar: function() {
this.setData({
shopType: "addShopCar"
})
this.bindGuiGeTap();
},
async tobuy() {
const token = wx.getStorageSync('token')
if (!token) {
wx.showToast({
title: '请先登陆',
icon: 'none'
})
return
}
const res = await WXAPI.cpsPddGoodsShotUrl(token, this.data.goodsDetail.basicInfo.yyIdStr)
if (res.code != 0) {
wx.showToast({
title: res.msg,
icon: 'none'
})
return
}
wx.navigateToMiniProgram({
appId: res.data.we_app_info.app_id,
path: res.data.we_app_info.page_path
})
},
toPingtuan: function(e) {
let pingtuanopenid = 0
if (e.currentTarget.dataset.pingtuanopenid) {
pingtuanopenid = e.currentTarget.dataset.pingtuanopenid
}
this.setData({
shopType: "toPingtuan",
selectSizePrice: this.data.goodsDetail.basicInfo.pingtuanPrice,
selectSizeOPrice: this.data.goodsDetail.basicInfo.originalPrice,
pingtuanopenid: pingtuanopenid,
hideShopPopup: false,
skuGoodsPic: this.data.goodsDetail.basicInfo.pic
});
},
/**
* 规格选择弹出框
*/
bindGuiGeTap: function() {
this.setData({
hideShopPopup: false
})
},
/**
* 规格选择弹出框隐藏
*/
closePopupTap: function() {
this.setData({
hideShopPopup: true
})
},
stepChange(event) {
this.setData({
buyNumber: event.detail
})
},
/**
* 选择商品规格
*/
async labelItemTap(e) {
const propertyindex = e.currentTarget.dataset.propertyindex
const propertychildindex = e.currentTarget.dataset.propertychildindex
const property = this.data.goodsDetail.properties[propertyindex]
const child = property.childsCurGoods[propertychildindex]
// 取消该分类下的子栏目所有的选中状态
property.childsCurGoods.forEach(child => {
child.active = false
})
// 设置当前选中状态
property.optionValueId = child.id
child.active = true
// 获取所有的选中规格尺寸数据
const needSelectNum = this.data.goodsDetail.properties.length
let curSelectNum = 0;
let propertyChildIds = "";
let propertyChildNames = "";
this.data.goodsDetail.properties.forEach(p => {
p.childsCurGoods.forEach(c => {
if (c.active) {
curSelectNum++;
propertyChildIds = propertyChildIds + p.id + ":" + c.id + ",";
propertyChildNames = propertyChildNames + p.name + ":" + c.name + " ";
}
})
})
let canSubmit = false;
if (needSelectNum == curSelectNum) {
canSubmit = true;
}
let skuGoodsPic = this.data.skuGoodsPic
if (this.data.goodsDetail.subPics && this.data.goodsDetail.subPics.length > 0) {
const _subPic = this.data.goodsDetail.subPics.find(ele => {
return ele.optionValueId == child.id
})
if (_subPic) {
skuGoodsPic = _subPic.pic
}
}
this.setData({
goodsDetail: this.data.goodsDetail,
canSubmit,
skuGoodsPic,
propertyChildIds,
propertyChildNames,
})
this.calculateGoodsPrice()
},
async calculateGoodsPrice() {
// 计算最终的商品价格
let price = this.data.goodsDetail.basicInfo.minPrice
let originalPrice = this.data.goodsDetail.basicInfo.originalPrice
let totalScoreToPay = this.data.goodsDetail.basicInfo.minScore
let buyNumMax = this.data.goodsDetail.basicInfo.stores
let buyNumber = this.data.goodsDetail.basicInfo.minBuyNumber
if (this.data.shopType == 'toPingtuan') {
price = this.data.goodsDetail.basicInfo.pingtuanPrice
}
// 计算 sku 价格
if (this.data.canSubmit) {
const token = wx.getStorageSync('token')
const res = await WXAPI.goodsPriceV2({
token: token ? token : '',
goodsId: this.data.goodsDetail.basicInfo.id,
propertyChildIds: this.data.propertyChildIds
})
if (res.code == 0) {
price = res.data.price
if (this.data.shopType == 'toPingtuan') {
price = res.data.pingtuanPrice
}
originalPrice = res.data.originalPrice
totalScoreToPay = res.data.score
buyNumMax = res.data.stores
}
}
// 计算配件价格
if (this.data.goodsAddition) {
this.data.goodsAddition.forEach(big => {
big.items.forEach(small => {
if (small.active) {
price = (price*100 + small.price*100) / 100
}
})
})
}
this.setData({
selectSizePrice: price,
selectSizeOPrice: originalPrice,
totalScoreToPay: totalScoreToPay,
buyNumMax,
buyNumber: (buyNumMax > buyNumber) ? buyNumber : 0
});
},
/**
* 选择可选配件
*/
async labelItemTap2(e) {
const propertyindex = e.currentTarget.dataset.propertyindex
const propertychildindex = e.currentTarget.dataset.propertychildindex
const goodsAddition = this.data.goodsAddition
const property = goodsAddition[propertyindex]
const child = property.items[propertychildindex]
if (child.active) {
// 该操作为取消选择
child.active = false
this.setData({
goodsAddition
})
this.calculateGoodsPrice()
return
}
// 单选配件取消所有子栏目选中状态
if (property.type == 0) {
property.items.forEach(child => {
child.active = false
})
}
// 设置当前选中状态
child.active = true
this.setData({
goodsAddition
})
this.calculateGoodsPrice()
},
/**
* 组建立即购买信息
*/
buliduBuyNowInfo: function(shoptype) {
var shopCarMap = {};
shopCarMap.goodsId = this.data.goodsId;
shopCarMap.pic = this.data.imageDomain + this.data.price.pic;
shopCarMap.name = this.data.price.skuName;
shopCarMap.price = this.data.price.priceSale;
shopCarMap.left = "";
shopCarMap.active = true;
shopCarMap.number = this.data.buyNumber;
var buyNowInfo = {};
buyNowInfo.shopNum = 0;
buyNowInfo.shopList = [shopCarMap];
return buyNowInfo;
},
onShareAppMessage() {
let _data = {
title: this.data.goodsDetail.basicInfo.name,
path: '/packageCps/pages/goods-details/cps-pdd?id=' + this.data.goodsId + '&inviter_id=' + wx.getStorageSync('uid'),
success: function(res) {
// 转发成功
},
fail: function(res) {
// 转发失败
}
}
if (this.data.kjJoinUid) {
_data.title = this.data.curKanjiaprogress.joiner.nick + '邀请您帮TA砍价'
_data.path += '&kjJoinUid=' + this.data.kjJoinUid
}
return _data
},
reputation: function(goodsId) {
var that = this;
WXAPI.goodsReputation({
goodsId: goodsId
}).then(function(res) {
if (res.code == 0) {
res.data.forEach(ele => {
if (ele.goods.goodReputation == 0) {
ele.goods.goodReputation = 1
} else if (ele.goods.goodReputation == 1) {
ele.goods.goodReputation = 3
} else if (ele.goods.goodReputation == 2) {
ele.goods.goodReputation = 5
}
})
that.setData({
reputation: res.data
});
}
})
},
pingtuanList: function(goodsId) {
var that = this;
WXAPI.pingtuanList({
goodsId: goodsId,
status: 0
}).then(function(res) {
if (res.code == 0) {
that.setData({
pingtuanList: res.data.result
});
}
})
},
getVideoSrc: function(videoId) {
var that = this;
WXAPI.videoDetail(videoId).then(function(res) {
if (res.code == 0) {
that.setData({
videoMp4Src: res.data.fdMp4
});
}
})
},
joinKanjia(){
AUTH.checkHasLogined().then(isLogined => {
if (isLogined) {
this.doneJoinKanjia();
} else {
this.setData({
wxlogin: false
})
}
})
},
doneJoinKanjia: function() { // 报名参加砍价活动
const _this = this;
if (!_this.data.curGoodsKanjia) {
return;
}
wx.showLoading({
title: '加载中',
mask: true
})
WXAPI.kanjiaJoin(wx.getStorageSync('token'), _this.data.curGoodsKanjia.id).then(function(res) {
wx.hideLoading()
if (res.code == 0) {
_this.setData({
kjJoinUid: wx.getStorageSync('uid'),
myHelpDetail: null
})
_this.getGoodsDetailAndKanjieInfo(_this.data.goodsDetail.basicInfo.id)
} else {
wx.showToast({
title: res.msg,
icon: 'none'
})
}
})
},
joinPingtuan: function(e) {
let pingtuanopenid = e.currentTarget.dataset.pingtuanopenid
wx.navigateTo({
url: "/pages/to-pay-order/index?orderType=buyNow&pingtuanOpenId=" + pingtuanopenid
})