parent
c9f3f7f6ff
commit
dcbe6241f0
64
api/user.js
64
api/user.js
|
@ -2,7 +2,7 @@ import request from "@/utils/request.js";
|
||||||
import Cache from "@/utils/cache.js"
|
import Cache from "@/utils/cache.js"
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getUserInfo(){
|
export function getUserInfo(){
|
||||||
return request.get('user');
|
return request.get('user');
|
||||||
|
@ -10,7 +10,7 @@ export function getUserInfo(){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置用户分享
|
* 设置用户分享
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function userShare(){
|
export function userShare(){
|
||||||
return request.post('user/share');
|
return request.post('user/share');
|
||||||
|
@ -80,7 +80,7 @@ export function postSignUser(sign) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取签到配置
|
* 获取签到配置
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getSignConfig(){
|
export function getSignConfig(){
|
||||||
return request.get('user/sign/config')
|
return request.get('user/sign/config')
|
||||||
|
@ -104,7 +104,7 @@ export function setSignIntegral(){
|
||||||
/**
|
/**
|
||||||
* 签到列表(年月)
|
* 签到列表(年月)
|
||||||
* @param object data
|
* @param object data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getSignMonthList(data){
|
export function getSignMonthList(data){
|
||||||
return request.get('user/sign/month',data)
|
return request.get('user/sign/month',data)
|
||||||
|
@ -112,7 +112,7 @@ export function getSignMonthList(data){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动状态
|
* 活动状态
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function userActivity(){
|
export function userActivity(){
|
||||||
return request.get('user/activity');
|
return request.get('user/activity');
|
||||||
|
@ -133,7 +133,7 @@ export function getRecordApi(q) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 提现总金额
|
* 提现总金额
|
||||||
* */
|
* */
|
||||||
export function getCountApi() {
|
export function getCountApi() {
|
||||||
return request.get("extract/totalMoney");
|
return request.get("extract/totalMoney");
|
||||||
|
@ -148,7 +148,7 @@ export function getIntegralList(q) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分销海报图片
|
* 获取分销海报图片
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function spreadBanner(data){
|
export function spreadBanner(data){
|
||||||
return request.get('user/spread/banner',data);
|
return request.get('user/spread/banner',data);
|
||||||
|
@ -164,7 +164,7 @@ export function spreadPeople(data){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 推广佣金/提现总和
|
* 推广佣金/提现总和
|
||||||
* @param int type
|
* @param int type
|
||||||
*/
|
*/
|
||||||
|
@ -181,7 +181,7 @@ export function getSpreadInfo() {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 推广订单
|
* 推广订单
|
||||||
* @param object data
|
* @param object data
|
||||||
*/
|
*/
|
||||||
|
@ -213,7 +213,7 @@ export function extractCash(data){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提现银行/提现最低金额
|
* 提现银行/提现最低金额
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function extractBank(){
|
export function extractBank(){
|
||||||
return request.get('extract/bank');
|
return request.get('extract/bank');
|
||||||
|
@ -221,7 +221,7 @@ export function extractBank(){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员等级列表
|
* 会员等级列表
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function userLevelGrade(){
|
export function userLevelGrade(){
|
||||||
return request.get('user/level/grade');
|
return request.get('user/level/grade');
|
||||||
|
@ -237,14 +237,14 @@ export function userLevelTask(id){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户是否可以成为会员
|
* 检查用户是否可以成为会员
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function userLevelDetection(){
|
export function userLevelDetection(){
|
||||||
return request.get('user/level/detection');
|
return request.get('user/level/detection');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 地址列表
|
* 地址列表
|
||||||
* @param object data
|
* @param object data
|
||||||
*/
|
*/
|
||||||
|
@ -271,7 +271,7 @@ export function editAddress(data){
|
||||||
/**
|
/**
|
||||||
* 删除地址
|
* 删除地址
|
||||||
* @param int id
|
* @param int id
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function delAddress(id){
|
export function delAddress(id){
|
||||||
return request.post('address/del',{id:id})
|
return request.post('address/del',{id:id})
|
||||||
|
@ -279,7 +279,7 @@ export function delAddress(id){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个地址
|
* 获取单个地址
|
||||||
* @param int id
|
* @param int id
|
||||||
*/
|
*/
|
||||||
export function getAddressDetail(id){
|
export function getAddressDetail(id){
|
||||||
return request.get('address/detail/'+id);
|
return request.get('address/detail/'+id);
|
||||||
|
@ -301,7 +301,7 @@ export function getLogout() {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 小程序充值
|
* 小程序充值
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function rechargeRoutine(data){
|
export function rechargeRoutine(data){
|
||||||
return request.post('recharge/routine',data)
|
return request.post('recharge/routine',data)
|
||||||
|
@ -329,7 +329,7 @@ export function transferIn(data) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取默认地址
|
* 获取默认地址
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getAddressDefault(){
|
export function getAddressDefault(){
|
||||||
return request.get('address/default');
|
return request.get('address/default');
|
||||||
|
@ -374,7 +374,7 @@ export function spread(puid)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前用户在佣金排行第几名
|
* 当前用户在佣金排行第几名
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function brokerageRankNumber(data)
|
export function brokerageRankNumber(data)
|
||||||
{
|
{
|
||||||
|
@ -383,7 +383,7 @@ export function brokerageRankNumber(data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员等级经验值;
|
* 会员等级经验值;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getlevelInfo()
|
export function getlevelInfo()
|
||||||
{
|
{
|
||||||
|
@ -392,7 +392,7 @@ export function getlevelInfo()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 经验值明细;
|
* 经验值明细;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getlevelExpList(data)
|
export function getlevelExpList(data)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +401,7 @@ export function getlevelExpList(data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 经验值明细;
|
* 经验值明细;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getuserDalance()
|
export function getuserDalance()
|
||||||
{
|
{
|
||||||
|
@ -411,7 +411,7 @@ export function getuserDalance()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账单记录;
|
* 账单记录;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function getBillList(data)
|
export function getBillList(data)
|
||||||
{
|
{
|
||||||
|
@ -438,23 +438,3 @@ export function extractUser() {
|
||||||
export function spreadPeoCount() {
|
export function spreadPeoCount() {
|
||||||
return request.get("spread/people/count");
|
return request.get("spread/people/count");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
统计
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export function computeUser(){
|
|
||||||
uni.request({
|
|
||||||
url: document.location.protocol + '//shop.crmeb.net/index.php/admin/server.upgrade_api/updatewebinfo',
|
|
||||||
method:'POST',
|
|
||||||
data: {
|
|
||||||
host:window.location.host,
|
|
||||||
https:document.location.protocol,
|
|
||||||
version:'CRMEB-JAVA-KY-V1.3.4',
|
|
||||||
version_code:'gitee',
|
|
||||||
ip:Cache.has('Ip') ? Cache.get('Ip') : ''
|
|
||||||
},
|
|
||||||
dataType:'json',
|
|
||||||
success: (res) => {}
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -53,13 +53,16 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- TODO 芋艿:拼团 -->
|
||||||
<view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock > 0 && attr.productSelect.quota > 0"
|
<view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock > 0 && attr.productSelect.quota > 0"
|
||||||
@click="goCat">我要参团</view>
|
@click="goCat">我要参团</view>
|
||||||
<view class="joinBnt on"
|
<view class="joinBnt on"
|
||||||
v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
|
v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
|
||||||
<view class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock" @click="goCat">确定</view>
|
<!-- TODO 芋艿:购物车 -->
|
||||||
<!-- <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock && attr.productSelect.quota" @click="goCat">确定</view> -->
|
<view class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock"
|
||||||
<view class="joinBnt on" v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
|
@click="goCat">确定</view>
|
||||||
|
<view class="joinBnt on"
|
||||||
|
v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
|
<view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -80,15 +83,15 @@
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
iSbnt: {
|
iSbnt: { // 是否拼团商品
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
iSplus: {
|
iSplus: { // 是否允许 + - 操作
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
iScart: {
|
iScart: { // 是否来自购物车界面
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
|
@ -105,15 +108,18 @@
|
||||||
* 购物车手动输入数量
|
* 购物车手动输入数量
|
||||||
*/
|
*/
|
||||||
bindCode: function(e) {
|
bindCode: function(e) {
|
||||||
|
// TODO 芋艿:【优化】方法名的处理;是否可去掉这个事件,统一处理
|
||||||
this.$emit('iptCartNum', this.attr.productSelect.cart_num);
|
this.$emit('iptCartNum', this.attr.productSelect.cart_num);
|
||||||
},
|
},
|
||||||
closeAttr: function() {
|
closeAttr: function() {
|
||||||
this.$emit('myevent');
|
this.attr.cartAttr = false
|
||||||
},
|
},
|
||||||
CartNumDes: function() {
|
CartNumDes: function() {
|
||||||
|
// TODO 芋艿:【优化】方法名的处理;是否可去掉这个事件,统一处理
|
||||||
this.$emit('ChangeCartNum', false);
|
this.$emit('ChangeCartNum', false);
|
||||||
},
|
},
|
||||||
CartNumAdd: function() {
|
CartNumAdd: function() {
|
||||||
|
// TODO 芋艿:【优化】方法名的处理;是否可去掉这个事件,统一处理
|
||||||
this.$emit('ChangeCartNum', true);
|
this.$emit('ChangeCartNum', true);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -125,6 +131,7 @@
|
||||||
clickProperty: function(indexw, indexn) {
|
clickProperty: function(indexw, indexn) {
|
||||||
this.$set(this.attr.properties[indexw], 'index', this.attr.properties[indexw].values[indexn].name);
|
this.$set(this.attr.properties[indexw], 'index', this.attr.properties[indexw].values[indexn].name);
|
||||||
let newSkuKey = this.getCheckedValueNames().join(",");
|
let newSkuKey = this.getCheckedValueNames().join(",");
|
||||||
|
// TODO 芋艿:【优化】修改下 ChangeAttr 名字,改成 selectSku 更合适
|
||||||
this.$emit("ChangeAttr", newSkuKey);
|
this.$emit("ChangeAttr", newSkuKey);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -178,10 +178,10 @@
|
||||||
<view class='iconfont icon-shoucang' v-else></view>
|
<view class='iconfont icon-shoucang' v-else></view>
|
||||||
<view>收藏</view>
|
<view>收藏</view>
|
||||||
</view>
|
</view>
|
||||||
<navigator open-type='switchTab' class="animated item" :class="animated ? 'bounceIn':''"
|
<navigator open-type='switchTab' class="animated item" :class="cartAnimated ? 'bounceIn':''"
|
||||||
url='/pages/order_addcart/order_addcart' hover-class="none">
|
url='/pages/order_addcart/order_addcart' hover-class="none">
|
||||||
<view class='iconfont icon-gouwuche1'>
|
<view class='iconfont icon-gouwuche1'>
|
||||||
<text v-if="CartCount > 0" class='num bg-color'>{{CartCount}}</text>
|
<text v-if="cartCount > 0" class='num bg-color'>{{ cartCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view>购物车</view>
|
<view>购物车</view>
|
||||||
</navigator>
|
</navigator>
|
||||||
|
@ -224,7 +224,6 @@
|
||||||
:attr="attr"
|
:attr="attr"
|
||||||
:isShow='1'
|
:isShow='1'
|
||||||
:iSplus='1'
|
:iSplus='1'
|
||||||
@myevent="onMyEvent"
|
|
||||||
@ChangeAttr="ChangeAttr"
|
@ChangeAttr="ChangeAttr"
|
||||||
@ChangeCartNum="ChangeCartNum"
|
@ChangeCartNum="ChangeCartNum"
|
||||||
@iptCartNum="iptCartNum"
|
@iptCartNum="iptCartNum"
|
||||||
|
@ -285,7 +284,6 @@
|
||||||
import {
|
import {
|
||||||
collectAdd,
|
collectAdd,
|
||||||
collectDel,
|
collectDel,
|
||||||
postCartAdd,
|
|
||||||
getReplyConfig,
|
getReplyConfig,
|
||||||
getProductGood,
|
getProductGood,
|
||||||
getReplyProduct
|
getReplyProduct
|
||||||
|
@ -294,13 +292,9 @@
|
||||||
import {
|
import {
|
||||||
getCoupons
|
getCoupons
|
||||||
} from '@/api/api.js';
|
} from '@/api/api.js';
|
||||||
import {
|
|
||||||
getCartCounts
|
|
||||||
} from '@/api/order.js';
|
|
||||||
import {
|
import {
|
||||||
toLogin
|
toLogin
|
||||||
} from '@/libs/login.js';
|
} from '@/libs/login.js';
|
||||||
import {computeUser} from "@/api/user.js";
|
|
||||||
import {
|
import {
|
||||||
mapGetters
|
mapGetters
|
||||||
} from "vuex";
|
} from "vuex";
|
||||||
|
@ -315,6 +309,7 @@
|
||||||
import home from '@/components/home';
|
import home from '@/components/home';
|
||||||
import parser from "@/components/jyf-parser/jyf-parser";
|
import parser from "@/components/jyf-parser/jyf-parser";
|
||||||
import * as ProductSpuApi from '@/api/product/spu.js';
|
import * as ProductSpuApi from '@/api/product/spu.js';
|
||||||
|
import * as TradeCartApi from '@/api/trade/cart.js';
|
||||||
import * as Util from '@/utils/util.js';
|
import * as Util from '@/utils/util.js';
|
||||||
import * as ProductUtil from '@/utils/product.js';
|
import * as ProductUtil from '@/utils/product.js';
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
|
@ -360,8 +355,8 @@
|
||||||
properties: [],
|
properties: [],
|
||||||
productSelect: {} // 选中的 SKU
|
productSelect: {} // 选中的 SKU
|
||||||
},
|
},
|
||||||
CartCount: 0, // 购物车数量
|
cartCount: 0, // 购物车的数量
|
||||||
animated: false, // 购物车动画
|
cartAnimated: false, // 购物车的动画开关
|
||||||
replyCount: 0, // 总评论数量 TODO 芋艿:回复,待实现
|
replyCount: 0, // 总评论数量 TODO 芋艿:回复,待实现
|
||||||
reply: [], // 评论列表
|
reply: [], // 评论列表
|
||||||
replyChance: 0, // TODO 芋艿:评论相关,待接入
|
replyChance: 0, // TODO 芋艿:评论相关,待接入
|
||||||
|
@ -370,7 +365,6 @@
|
||||||
cart_num: 1, // 购买数量 TODO 芋艿:待实现
|
cart_num: 1, // 购买数量 TODO 芋艿:待实现
|
||||||
isAuto: false, // 没有授权的不会自动授权 TODO 芋艿:待实现
|
isAuto: false, // 没有授权的不会自动授权 TODO 芋艿:待实现
|
||||||
isShowAuth: false, // 是否隐藏授权 TODO 芋艿:待实现
|
isShowAuth: false, // 是否隐藏授权 TODO 芋艿:待实现
|
||||||
isOpen: false, // 是否打开属性组件 TODO 芋艿:是不是可以移除,貌似和 attr.cartAttr 重复
|
|
||||||
actionSheetHidden: true, // TODO 芋艿:没搞懂
|
actionSheetHidden: true, // TODO 芋艿:没搞懂
|
||||||
storeImage: '', // 海报产品图 // TODO 芋艿:没搞懂
|
storeImage: '', // 海报产品图 // TODO 芋艿:没搞懂
|
||||||
PromotionCode: '', // 二维码图片 // TODO 芋艿:没搞懂
|
PromotionCode: '', // 二维码图片 // TODO 芋艿:没搞懂
|
||||||
|
@ -439,11 +433,9 @@
|
||||||
that.retunTop = false
|
that.retunTop = false
|
||||||
}
|
}
|
||||||
that.navH = app.globalData.navHeight;
|
that.navH = app.globalData.navHeight;
|
||||||
// #ifdef H5
|
|
||||||
computeUser();
|
|
||||||
// #endif
|
|
||||||
// #ifdef MP || APP-PLUS
|
// #ifdef MP || APP-PLUS
|
||||||
// 小程序链接进入获取绑定关系id
|
// 小程序链接进入获取绑定关系id
|
||||||
|
// TODO 芋艿:分销???
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
if(options.spread){
|
if(options.spread){
|
||||||
app.globalData.spread = options.spread;
|
app.globalData.spread = options.spread;
|
||||||
|
@ -457,7 +449,6 @@
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!options.scene && !options.id) {
|
if (!options.scene && !options.id) {
|
||||||
this.showSkeleton = false;
|
|
||||||
this.$util.Tips({
|
this.$util.Tips({
|
||||||
title: '缺少参数无法查看商品'
|
title: '缺少参数无法查看商品'
|
||||||
}, {
|
}, {
|
||||||
|
@ -474,7 +465,6 @@
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
|
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
|
||||||
},2000)
|
},2000)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.id = options.id;
|
this.id = options.id;
|
||||||
}
|
}
|
||||||
|
@ -568,10 +558,11 @@
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 购物车手动填写
|
* 购物车手动填写
|
||||||
*
|
*
|
||||||
|
* @param number 数量
|
||||||
*/
|
*/
|
||||||
iptCartNum: function(e) {
|
iptCartNum: function(number) {
|
||||||
this.$set(this.attr.productSelect, 'cart_num', e ? e : 1);
|
this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
|
||||||
},
|
},
|
||||||
// 后退
|
// 后退
|
||||||
returns: function() {
|
returns: function() {
|
||||||
|
@ -579,7 +570,6 @@
|
||||||
},
|
},
|
||||||
tap: function(index) {
|
tap: function(index) {
|
||||||
var id = "past" + index;
|
var id = "past" + index;
|
||||||
var index = index;
|
|
||||||
var that = this;
|
var that = this;
|
||||||
this.$set(this, 'toView', id);
|
this.$set(this, 'toView', id);
|
||||||
this.$set(this, 'navActive', index);
|
this.$set(this, 'navActive', index);
|
||||||
|
@ -653,27 +643,27 @@
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 购物车数量加和数量减
|
* 购物车数量加和数量减
|
||||||
|
*
|
||||||
|
* @param changeValue true 增加;false 减少
|
||||||
*/
|
*/
|
||||||
ChangeCartNum: function(changeValue) {
|
ChangeCartNum: function(changeValue) {
|
||||||
//changeValue:是否 加|减
|
// 获取当前 sku
|
||||||
//获取当前变动属性
|
let sku = this.attr.productSelect;
|
||||||
let productSelect = this.skuMap[this.attrValue];
|
if (!sku) {
|
||||||
//如果没有属性,赋值给商品默认库存
|
return;
|
||||||
if (productSelect === undefined && !this.attr.properties.length)
|
}
|
||||||
productSelect = this.attr.productSelect;
|
|
||||||
//无属性值即库存为0;不存在加减;
|
// 设置数量
|
||||||
if (productSelect === undefined) return;
|
let stock = sku.stock || 0;
|
||||||
let stock = productSelect.stock || 0;
|
|
||||||
let num = this.attr.productSelect;
|
|
||||||
if (changeValue) {
|
if (changeValue) {
|
||||||
num.cart_num++;
|
sku.cart_num++;
|
||||||
if (num.cart_num > stock) {
|
if (sku.cart_num > stock) {
|
||||||
this.$set(this.attr.productSelect, "cart_num", stock);
|
this.$set(this.attr.productSelect, "cart_num", stock);
|
||||||
this.$set(this, "cart_num", stock);
|
this.$set(this, "cart_num", stock);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
num.cart_num--;
|
sku.cart_num--;
|
||||||
if (num.cart_num < 1) {
|
if (sku.cart_num < 1) {
|
||||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||||
this.$set(this, "cart_num", 1);
|
this.$set(this, "cart_num", 1);
|
||||||
}
|
}
|
||||||
|
@ -739,7 +729,7 @@
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (good_list.length) {
|
if (good_list.length) {
|
||||||
this.setClientHeight();
|
this.setClientHeight();
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -758,7 +748,7 @@
|
||||||
that.$set(that, 'userCollect', res.data.userCollect); // TODO 芋艿:需要改造下,异步加载收藏状态
|
that.$set(that, 'userCollect', res.data.userCollect); // TODO 芋艿:需要改造下,异步加载收藏状态
|
||||||
that.$set(that.attr, 'properties', ProductUtil.convertProductPropertyList(skus));
|
that.$set(that.attr, 'properties', ProductUtil.convertProductPropertyList(skus));
|
||||||
that.$set(that, 'skuMap', ProductUtil.convertProductSkuMap(skus));
|
that.$set(that, 'skuMap', ProductUtil.convertProductSkuMap(skus));
|
||||||
that.$set(that.sharePacket, 'priceName', res.data.priceName);
|
that.$set(that.sharePacket, 'priceName', res.data.priceName); // TODO 芋艿:share packet 不知道干啥
|
||||||
that.$set(that.sharePacket, 'isState', Math.floor(res.data.priceName) === 0);
|
that.$set(that.sharePacket, 'isState', Math.floor(res.data.priceName) === 0);
|
||||||
that.$set(that, 'activityH5', res.data.activityAllH5 ? res.data.activityAllH5 : []);
|
that.$set(that, 'activityH5', res.data.activityAllH5 ? res.data.activityAllH5 : []);
|
||||||
// 设置标题
|
// 设置标题
|
||||||
|
@ -828,7 +818,7 @@
|
||||||
that.$set(that, 'topArr', topArr);
|
that.$set(that, 'topArr', topArr);
|
||||||
that.$set(that, 'heightArr', heightArr);
|
that.$set(that, 'heightArr', heightArr);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 拨打电话
|
* 拨打电话
|
||||||
|
@ -924,8 +914,6 @@
|
||||||
that.$set(that.coupon, 'coupon', false);
|
that.$set(that.coupon, 'coupon', false);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* 收藏商品
|
* 收藏商品
|
||||||
*/
|
*/
|
||||||
setCollect: function() {
|
setCollect: function() {
|
||||||
|
@ -949,7 +937,6 @@
|
||||||
*/
|
*/
|
||||||
openAttr: function() {
|
openAttr: function() {
|
||||||
this.$set(this.attr, 'cartAttr', true);
|
this.$set(this.attr, 'cartAttr', true);
|
||||||
this.$set(this, 'isOpen', true);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 打开优惠券插件
|
* 打开优惠券插件
|
||||||
|
@ -963,116 +950,93 @@
|
||||||
that.$set(that.coupon, 'coupon', true);
|
that.$set(that.coupon, 'coupon', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMyEvent: function() {
|
|
||||||
this.$set(this.attr, 'cartAttr', false);
|
|
||||||
this.$set(this, 'isOpen', false);
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* 打开属性加入购物车
|
* 打开属性加入购物车
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
joinCart: function(e) {
|
joinCart: function() {
|
||||||
//是否登录
|
// 未登录,需要跳转
|
||||||
if (this.isLogin === false) {
|
if (!this.isLogin) {
|
||||||
toLogin();
|
toLogin();
|
||||||
} else {
|
return;
|
||||||
this.goCat(1);
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
/*
|
// 【重要】如果 attr 组件未打开,此时需要先打开。等到选择完后,再添加购物车
|
||||||
* 加入购物车
|
if (!this.attr.cartAttr) {
|
||||||
*/
|
this.openAttr();
|
||||||
goCat: function(num) {
|
return
|
||||||
let that = this,
|
}
|
||||||
productSelect = that.skuMap[this.attrValue];
|
|
||||||
//打开属性
|
// 库存不足
|
||||||
if (that.attrValue) {
|
let sku = this.attr.productSelect;
|
||||||
//默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性
|
if (sku.stock === 0) {
|
||||||
that.attr.cartAttr = !that.isOpen ? true : false;
|
return that.$util.Tips({
|
||||||
} else {
|
title: "产品库存不足,请选择其它"
|
||||||
if (that.isOpen) that.attr.cartAttr = true;
|
});
|
||||||
else that.attr.cartAttr = !that.attr.cartAttr;
|
}
|
||||||
}
|
|
||||||
//只有关闭属性弹窗时进行加入购物车
|
// 添加购物车
|
||||||
if (that.attr.cartAttr === true && that.isOpen === false)
|
TradeCartApi.addCart({
|
||||||
return (that.isOpen = true);
|
count: sku.cart_num,
|
||||||
//如果有属性,没有选择,提示用户选择
|
skuId: sku.id,
|
||||||
if (
|
addStatus: true // TODO 芋艿:去掉 addStatus 字段
|
||||||
that.attr.properties.length &&
|
}).then(res => {
|
||||||
productSelect.stock === 0 &&
|
// 关闭 attr 组件
|
||||||
that.isOpen === true
|
this.attr.cartAttr = false;
|
||||||
)
|
// 提示成功
|
||||||
return that.$util.Tips({
|
this.$util.Tips({
|
||||||
title: "产品库存不足,请选择其它"
|
title: "添加购物车成功",
|
||||||
});
|
success: () => {
|
||||||
if (num === 1) {
|
this.getCartCount(true);
|
||||||
let q = {
|
}
|
||||||
productId: parseFloat(that.id),
|
});
|
||||||
cartNum: parseFloat(that.attr.productSelect.cart_num),
|
}).catch(res => {
|
||||||
isNew: false,
|
this.$util.Tips({
|
||||||
propertiesUnique: that.attr.productSelect !== undefined ?
|
title: res
|
||||||
that.attr.productSelect.unique : that.productInfo.id
|
});
|
||||||
};
|
});
|
||||||
postCartAdd(q).then(function(res) {
|
},
|
||||||
that.isOpen = false;
|
|
||||||
that.attr.cartAttr = false;
|
|
||||||
that.$util.Tips({
|
|
||||||
title: "添加购物车成功",
|
|
||||||
success: () => {
|
|
||||||
that.getCartCount(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(res => {
|
|
||||||
that.isOpen = false;
|
|
||||||
return that.$util.Tips({
|
|
||||||
title: res
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.getPreOrder();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* 获取购物车数量
|
* 获取购物车数量
|
||||||
*
|
*
|
||||||
* @param isAnima 是否展示购物车动画和重置属性
|
* @param isAnima 是否展示购物车动画和重置属性
|
||||||
*/
|
*/
|
||||||
getCartCount: function(isAnima) {
|
getCartCount: function(isAnima) {
|
||||||
let that = this;
|
const isLogin = this.isLogin;
|
||||||
const isLogin = that.isLogin;
|
if (!isLogin) {
|
||||||
if (isLogin) {
|
return
|
||||||
getCartCounts(true, 'total').then(res => {
|
}
|
||||||
that.CartCount = res.data.count;
|
TradeCartApi.getCartCount().then(res => {
|
||||||
// 加入购物车后重置属性
|
this.cartCount = res.data;
|
||||||
if (isAnima) {
|
// 加入购物车后重置属性
|
||||||
that.animated = true;
|
if (isAnima) {
|
||||||
setTimeout(function() {
|
this.cartAnimated = true;
|
||||||
that.animated = false;
|
setTimeout(() => {
|
||||||
}, 500);
|
this.cartAnimated = false;
|
||||||
}
|
}, 500);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 立即购买
|
* 立即购买
|
||||||
*/
|
*/
|
||||||
goBuy: function(e) {
|
goBuy: function() {
|
||||||
if (this.isLogin === false) {
|
// 未登录,需要跳转
|
||||||
|
if (!this.isLogin) {
|
||||||
toLogin();
|
toLogin();
|
||||||
} else {
|
return;
|
||||||
this.goCat(0);
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
/**
|
// 【重要】如果 attr 组件未打开,此时需要先打开。等到选择完后,再立即购买
|
||||||
* 预下单
|
if (!this.attr.cartAttr) {
|
||||||
*/
|
this.openAttr();
|
||||||
getPreOrder: function() {
|
return;
|
||||||
this.$Order.getPreOrder(this.type === 'normal' ? 'buyNow' : 'video', [{
|
}
|
||||||
"attrValueId": parseFloat(this.attr.productSelect.unique),
|
|
||||||
"productId": parseFloat(this.id),
|
// 发起下单
|
||||||
"productNum": parseFloat(this.attr.productSelect.cart_num)
|
let sku = this.attr.productSelect;
|
||||||
}]);
|
uni.navigateTo({
|
||||||
|
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 授权关闭
|
// 授权关闭
|
||||||
authColse: function(e) {
|
authColse: function(e) {
|
||||||
|
@ -1080,7 +1044,6 @@
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 分享打开
|
* 分享打开
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
listenerActionSheet: function() {
|
listenerActionSheet: function() {
|
||||||
if (this.isLogin === false) {
|
if (this.isLogin === false) {
|
||||||
|
|
|
@ -19,5 +19,5 @@ export function base64src(base64data, cb) {
|
||||||
return (new Error('ERROR_BASE64SRC_WRITE'));
|
return (new Error('ERROR_BASE64SRC_WRITE'));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
//module.exports = base64src;
|
//module.exports = base64src;
|
||||||
|
|
Loading…
Reference in New Issue