Feat:优惠券对接

This commit is contained in:
lifizer
2023-12-25 17:16:56 +08:00
parent 847a80f251
commit 18a2fbb8a6
46 changed files with 1360 additions and 858 deletions
+128 -123
View File
@@ -4,16 +4,16 @@ import request from "@/utils/request";
* 省市区 * 省市区
*/ */
export function getCity(data) { export function getCity(data) {
return request.get("/city_list", data, { return request.get("/city_list", data, {
login: false login: false
}); });
} }
export function district(data) { export function district(data) {
// return request.get("/city_list", data, { // return request.get("/city_list", data, {
return request.get("/citys", data, { return request.get("/citys", data, {
login: false login: false
}); });
} }
/** /**
@@ -21,9 +21,9 @@ export function district(data) {
* @param data object 用户账号密码 * @param data object 用户账号密码
*/ */
export function login(data) { export function login(data) {
return request.post("/login", data, { return request.post("/login", data, {
login: false login: false
}); });
} }
/** /**
@@ -31,9 +31,9 @@ export function login(data) {
* @param data object 用户手机号 也只能 * @param data object 用户手机号 也只能
*/ */
export function loginMobile(data) { export function loginMobile(data) {
return request.post("/login/mobile", data, { return request.post("/login/mobile", data, {
login: false login: false
}); });
} }
/** /**
@@ -41,9 +41,9 @@ export function loginMobile(data) {
* @param data object 用户手机号 * @param data object 用户手机号
*/ */
export function registerVerify(data) { export function registerVerify(data) {
return request.post("/register/verify", data, { return request.post("/register/verify", data, {
login: false login: false
}); });
} }
/** /**
@@ -51,9 +51,9 @@ export function registerVerify(data) {
* @param data object 用户手机号 验证码 密码 * @param data object 用户手机号 验证码 密码
*/ */
export function register(data) { export function register(data) {
return request.post("/register", data, { return request.post("/register", data, {
login: false login: false
}); });
} }
/** /**
@@ -61,9 +61,9 @@ export function register(data) {
* @param data object 用户手机号 验证码 密码 * @param data object 用户手机号 验证码 密码
*/ */
export function registerReset(data) { export function registerReset(data) {
return request.post("/register/reset", data, { return request.post("/register/reset", data, {
login: false login: false
}); });
} }
/** /**
@@ -71,7 +71,7 @@ export function registerReset(data) {
* @param nil * @param nil
*/ */
export function userBindParent(data) { export function userBindParent(data) {
return request.post("/user/spread", data); return request.post("/user/spread", data);
} }
/** /**
@@ -79,7 +79,7 @@ export function userBindParent(data) {
* @param nil * @param nil
*/ */
export function getUserLevelInfo() { export function getUserLevelInfo() {
return request.get("/user/levelInfo"); return request.get("/user/levelInfo");
} }
/** /**
@@ -87,7 +87,7 @@ export function getUserLevelInfo() {
* @param nil * @param nil
*/ */
export function saveUserProtocol(data) { export function saveUserProtocol(data) {
return request.post("/user/saveGd", data); return request.post("/user/saveGd", data);
} }
@@ -95,343 +95,346 @@ export function saveUserProtocol(data) {
* 视频回放列表 * 视频回放列表
* */ * */
export function getVideoList(q) { export function getVideoList(q) {
return request.get("/video_list", q, { return request.get("/video_list", q, {
login: false login: false
}); });
} }
/* /*
* 领取优惠券列表 * 领取优惠券列表
* */ * */
export function getCoupon(q) { export function getCoupon(q) {
return request.get("/coupons", q, { return request.get("/coupons", q, {
login: true login: true
}); });
} }
/* /*
* 点击领取优惠券 * 点击领取优惠券
* v9-2在用
* */ * */
export function getCouponReceive(id) { export function getCouponReceive(id) {
return request.post("/coupon/receive", { return request.post("/coupon/receive", {
couponId: id couponId: id
}, { }, {
login: true login: true
}); });
} }
/* /*
* 批量领取优惠券 * 批量领取优惠券
* */ * */
export function couponReceiveBatch(couponId) { export function couponReceiveBatch(couponId) {
return request.post("/coupon/receive/batch", { return request.post("/coupon/receive/batch", {
couponId couponId
}); });
} }
/* /*
* 我的优惠券 * 我的优惠券
* v9-2在用
* */ * */
export function getCouponsUser(type) { export function getCouponsUser(type) {
return request.get("/coupons/user/" + type); let url = '/coupons/user'
if (type !== undefined && type !== null) url += `?filterType=${type}`
return request.get(url)
} }
/* /*
* 个人中心 * 个人中心
* */ * */
export function getUser() { export function getUser() {
return request.get("/user"); return request.get("/user");
} }
/* /*
* 用户信息 * 用户信息
* */ * */
export function getUserInfo() { export function getUserInfo() {
return request.get("/userinfo", { return request.get("/userinfo", {
login: true login: true
}); });
} }
/* /*
* 小程序检查授权 * 小程序检查授权
* */ * */
export function wxappCheckAuth(data) { export function wxappCheckAuth(data) {
return request.post("/wxapp/checkAuthCode", data, { return request.post("/wxapp/checkAuthCode", data, {
login: false login: false
}); });
} }
/* /*
* 小程序登陆 * 小程序登陆
* */ * */
export function wxappAuth(data) { export function wxappAuth(data) {
return request.post("/wxapp/auth", data, { return request.post("/wxapp/auth", data, {
login: false login: false
}); });
} }
/* /*
* 个人中心(功能列表) * 个人中心(功能列表)
* */ * */
export function getMenuUser() { export function getMenuUser() {
return request.get("/menu/user"); return request.get("/menu/user");
} }
/* /*
* 用户设置支付密码 * 用户设置支付密码
* */ * */
export function setUserPayPwd(data) { export function setUserPayPwd(data) {
return request.post("/user/savePayPass", data); return request.post("/user/savePayPass", data);
} }
/* /*
* 通知消息列表 * 通知消息列表
* */ * */
export function noticeList(data) { export function noticeList(data) {
return request.get("/platNoticeSend/list", data, { login: true }); return request.get("/platNoticeSend/list", data, {login: true});
} }
/* /*
* 通知消息详情 * 通知消息详情
* */ * */
export function noticeDetail(data) { export function noticeDetail(data) {
return request.post("/platNoticeSend/read", data, { login: true }); return request.post("/platNoticeSend/read", data, {login: true});
} }
/* /*
* 用户修改支付密码 * 用户修改支付密码
* */ * */
export function modifyUserPayPwd(data) { export function modifyUserPayPwd(data) {
return request.post("/user/updatePayPass", data); return request.post("/user/updatePayPass", data);
} }
export function bankList(data) { export function bankList(data) {
return request.get("/api/yxBank/bank/list", data, { login: true }); return request.get("/api/yxBank/bank/list", data, {login: true});
} }
export function bankCardList(data) { export function bankCardList(data) {
return request.get("/api/yxBankCard/bankCard/list", data, { login: true }); return request.get("/api/yxBankCard/bankCard/list", data, {login: true});
} }
export function addBankCard(data) { export function addBankCard(data) {
return request.post("/api/yxBankCard/bankCard/add", data, { login: true }); return request.post("/api/yxBankCard/bankCard/add", data, {login: true});
} }
export function deleteBankCard(data) { export function deleteBankCard(data) {
return request.post("/api/yxBankCard/bankCard/del", data, { login: true }); return request.post("/api/yxBankCard/bankCard/del", data, {login: true});
} }
/* /*
* 地址列表 * 地址列表
* */ * */
export function getAddressList(data) { export function getAddressList(data) {
return request.get("/address/list", data || {}); return request.get("/address/list", data || {});
} }
/* /*
* 删除地址 * 删除地址
* */ * */
export function getAddressRemove(id) { export function getAddressRemove(id) {
return request.post("/address/del", { return request.post("/address/del", {
id: id id: id
}); });
} }
/* /*
* 设置默认地址 * 设置默认地址
* */ * */
export function getAddressDefaultSet(id) { export function getAddressDefaultSet(id) {
return request.post("/address/default/set", { return request.post("/address/default/set", {
id: id id: id
}); });
} }
/* /*
* 获取默认地址 * 获取默认地址
* */ * */
export function getAddressDefault() { export function getAddressDefault() {
return request.get("/address/default"); return request.get("/address/default");
} }
/* /*
* 获取单个地址 * 获取单个地址
* */ * */
export function getAddress(id) { export function getAddress(id) {
return request.get("/address/detail/" + id); return request.get("/address/detail/" + id);
} }
/* /*
* 修改 添加地址 * 修改 添加地址
* */ * */
export function postAddress(data) { export function postAddress(data) {
return request.post("/address/edit", data); return request.post("/address/edit", data);
} }
/* /*
* 获取收藏产品 * 获取收藏产品
* */ * */
export function getCollectUser(page, limit) { export function getCollectUser(page, limit) {
return request.get("/collect/user", { return request.get("/collect/user", {
page: page, page: page,
limit: limit limit: limit
}); });
} }
/* /*
* 删除收藏产品 * 删除收藏产品
* */ * */
export function getCollectDel(id, category) { export function getCollectDel(id, category) {
return request.post("/collect/del", { return request.post("/collect/del", {
id: id, id: id,
category: category category: category
}); });
} }
/* /*
* 批量收藏产品 * 批量收藏产品
* */ * */
export function postCollectAll(data) { export function postCollectAll(data) {
return request.post("/collect/all", data); return request.post("/collect/all", data);
} }
/* /*
* 添加收藏产品 * 添加收藏产品
* */ * */
export function getCollectAdd(id, category) { export function getCollectAdd(id, category) {
return request.post("collect/add", { return request.post("collect/add", {
id: id, id: id,
category: category category: category
}); });
} }
/* /*
* 签到配置 * 签到配置
* */ * */
export function getSignConfig() { export function getSignConfig() {
return request.get("/sign/config"); return request.get("/sign/config");
} }
/* /*
* 签到里的签到列表 * 签到里的签到列表
* */ * */
export function getSignList(page, limit) { export function getSignList(page, limit) {
return request.get("/sign/list", { return request.get("/sign/list", {
page: page, page: page,
limit: limit limit: limit
}); });
} }
/* /*
* 签到列表 * 签到列表
* */ * */
export function getSignMonth(page, limit) { export function getSignMonth(page, limit) {
return request.get("/sign/month", { return request.get("/sign/month", {
page: page, page: page,
limit: limit limit: limit
}); });
} }
/* /*
* 签到用户信息 * 签到用户信息
* */ * */
export function postSignUser(sign) { export function postSignUser(sign) {
return request.post("/sign/user", sign); return request.post("/sign/user", sign);
} }
/* /*
* 签到 * 签到
* */ * */
export function postSignIntegral(sign) { export function postSignIntegral(sign) {
return request.post("/sign/integral", sign); return request.post("/sign/integral", sign);
} }
/* /*
* 推广数据 * 推广数据
* */ * */
export function getSpreadInfo() { export function getSpreadInfo() {
return request.get("/commission"); return request.get("/commission");
} }
/* /*
* 推广人列表 * 推广人列表
* */ * */
export function getSpreadUser(screen) { export function getSpreadUser(screen) {
return request.post("/spread/people", screen); return request.post("/spread/people", screen);
} }
/* /*
* 推广人订单 * 推广人订单
* */ * */
export function getSpreadOrder(where) { export function getSpreadOrder(where) {
return request.post("/spread/order", where); return request.post("/spread/order", where);
} }
/* /*
* 资金明细(types|0=全部,1=消费,2=充值,3=返佣,4=提现) * 资金明细(types|0=全部,1=消费,2=充值,3=返佣,4=提现)
* */ * */
export function getCommissionInfo(q, types) { export function getCommissionInfo(q, types) {
return request.get("/spread/commission/" + types, q); return request.get("/spread/commission/" + types, q);
} }
/* /*
* 积分记录 * 积分记录
* */ * */
export function getIntegralList(q) { export function getIntegralList(q) {
return request.get("/integral/list", q); return request.get("/integral/list", q);
} }
/* /*
* 提现记录 * 提现记录
* */ * */
export function getWithdrawalRecordList(q) { export function getWithdrawalRecordList(q) {
return request.get("/list", q); return request.get("/list", q);
} }
/* /*
* 提现银行 * 提现银行
* */ * */
export function getBank() { export function getBank() {
return request.get("/extract/bank"); return request.get("/extract/bank");
} }
/* /*
* 提现申请 * 提现申请
* */ * */
export function postCashInfo(cash) { export function postCashInfo(cash) {
return request.post("/extract/cash", cash); return request.post("/extract/cash", cash);
} }
/* /*
* 会员中心 * 会员中心
* */ * */
export function getVipInfo() { export function getVipInfo() {
return request.get("/user/level/grade"); return request.get("/user/level/grade");
} }
/* /*
* 会员等级任务 * 会员等级任务
* */ * */
export function getVipTask(id) { export function getVipTask(id) {
return request.get("/user/level/task/" + id); return request.get("/user/level/task/" + id);
} }
/* /*
* 资金统计 * 资金统计
* */ * */
export function getBalance() { export function getBalance() {
return request.get("/user/balance"); return request.get("/user/balance");
} }
/* /*
* 活动状态 * 活动状态
* */ * */
export function getActivityStatus() { export function getActivityStatus() {
return request.get("/user/activity", {}, { return request.get("/user/activity", {}, {
login: false login: false
}); });
} }
/* /*
@@ -439,87 +442,89 @@ export function getActivityStatus() {
* */ * */
export function getSpreadImg(data) { export function getSpreadImg(data) {
return request.get("/spread/banner", data); return request.get("/spread/banner", data);
} }
/* /*
* 用户修改信息 * 用户修改信息
* */ * */
export function postUserEdit(data) { export function postUserEdit(data) {
return request.post("/user/edit", data); return request.post("/user/edit", data);
} }
/* /*
* 用户修改信息 * 用户修改信息
* */ * */
export function getChatRecord(to_uid, data) { export function getChatRecord(to_uid, data) {
return request.get("user/service/record/" + to_uid, data); return request.get("user/service/record/" + to_uid, data);
} }
/* /*
* 用户修改信息 * 用户修改信息
* */ * */
export function serviceList() { export function serviceList() {
return request.get("user/service/list"); return request.get("user/service/list");
} }
/* /*
* 公众号充值 * 公众号充值
* */ * */
export function rechargeWechat(data) { export function rechargeWechat(data) {
return request.post("/recharge/wechat", data); return request.post("/recharge/wechat", data);
} }
/* /*
* 退出登录 * 退出登录
* */ * */
export function getLogout() { export function getLogout() {
return request.post("/auth/logout"); return request.post("/auth/logout");
} }
/* /*
* 绑定手机号(小程序方式) * 绑定手机号(小程序方式)
* */ * */
export function bindingPhone(data) { export function bindingPhone(data) {
return request.post("wxapp/binding", data); return request.post("wxapp/binding", data);
} }
/* /*
* 绑定手机号(手机号,验证码方式) * 绑定手机号(手机号,验证码方式)
* */ * */
export function bindingPhoneByInput(data) { export function bindingPhoneByInput(data) {
return request.post("/binding", data); return request.post("/binding", data);
} }
/* /*
* h5切换公众号登陆 * h5切换公众号登陆
* */ * */
export function switchH5Login() { export function switchH5Login() {
return request.post("switch_h5", { return request.post("switch_h5", {
from: "wechat" from: "wechat"
}); });
} }
/* /*
* 获取推广人排行 * 获取推广人排行
* */ * */
export function getRankList(q) { export function getRankList(q) {
return request.get("rank", q); return request.get("rank", q);
} }
/* /*
* 获取佣金排名 * 获取佣金排名
* */ * */
export function getBrokerageRank(q) { export function getBrokerageRank(q) {
return request.get("brokerage_rank", q); return request.get("brokerage_rank", q);
} }
/** /**
* 检测会员等级 * 检测会员等级
*/ */
export function setDetection() { export function setDetection() {
return request.get("user/level/detection"); return request.get("user/level/detection");
} }
export function getRechargeApi() { export function getRechargeApi() {
return request.get("recharge/index"); return request.get("recharge/index");
} }
+1 -1
View File
@@ -16,6 +16,6 @@ export function fetchStore(page, cityName, name) {
* */ * */
export function fetchCity(type) { export function fetchCity(type) {
return request.get(`/wenwan/cityList/${type}`, {}, { return request.get(`/wenwan/cityList/${type}`, {}, {
login: false login: true
}) })
} }
+20 -4
View File
@@ -74,6 +74,19 @@
.cell:last-child { .cell:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
.coupon-label {
display: inline-block;
height: 46rpx;
box-sizing: border-box;
margin-right: 10rpx;
padding: 0 8rpx;
border: 2rpx solid #FD5749;
border-radius: 8rpx;
color: #FD5749;
font-size: 28rpx;
line-height: 46rpx;
}
} }
.store-section { .store-section {
@@ -111,14 +124,15 @@
height: 198rpx; height: 198rpx;
overflow: hidden; overflow: hidden;
.tag{ .tag {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 92rpx; width: 92rpx;
height: 40rpx; height: 40rpx;
} }
.cover{
.cover {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 12rpx; border-radius: 12rpx;
@@ -162,12 +176,14 @@
color: #ADADAD; color: #ADADAD;
} }
} }
.row:last-child{
.row:last-child {
border-bottom: none; border-bottom: none;
} }
.value { .value {
width: 100%; width: 100%;
padding: 16rpx; padding: 16rpx;
} }
} }
} }
+30 -6
View File
@@ -26,6 +26,15 @@ export default {
} }
}, },
levelJump: (level, url, params) => {
if (params) url += `?${params}`
if (level === 1) {
uni.switchTab({url})
} else {
uni.navigateTo({url})
}
},
navToGoods: (id) => { navToGoods: (id) => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/shop/GoodsCon/index?id=" + id url: "/pages/shop/GoodsCon/index?id=" + id
@@ -36,14 +45,14 @@ export default {
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: "wx9ca93d1f2a9c8156", appId: "wx9ca93d1f2a9c8156",
path: "pages/auth/login", path: "pages/auth/login",
success(msg){ success(msg) {
console.log("success",msg) console.log("success", msg)
}, },
fail(err){ fail(err) {
console.log("fail",err) console.log("fail", err)
}, },
complete(msg){ complete(msg) {
console.log("complete",msg) console.log("complete", msg)
} }
}) })
}, },
@@ -68,6 +77,21 @@ export default {
res += chars[id]; res += chars[id];
} }
return res; return res;
},
deepClone(val) {
let oVal = Array.isArray(val) ? [] : {};
for (let v in val) {
if (val.hasOwnProperty(v)) {
if ('object' === typeof val[v]) {
//这里是深拷贝的关键所在(递归调用)
oVal[v] = this.deepClone(val[v]);
} else {
oVal[v] = val[v];
}
}
}
return oVal;
} }
} }
+129
View File
@@ -0,0 +1,129 @@
<template>
<view class="components-coupons">
<image class="coupons__cover" :src="data.image" mode="scaleToFill"/>
<view class="coupons__section flex jc-between ai-center">
<view>有效期至
<text>{{ data.endTime }}</text>
</view>
<view class="coupons__tag coupons__tag-expire" v-if="data.status===2">已到期</view>
<view class="coupons__tag" @click="goGoods()" v-if="data.status===0 && !radioModel">去使用</view>
<view @click="selectCoupon">
<radio :value="data.id" :checked="data.checked" color="#FF564A" v-if="radioModel && data.status===0"/>
</view>
</view>
<view class="coupons__rules">
<view class="coupons__rules-title" @click="changeRules()">使用规则
<image :class="{'open':isOpen}" :src="webUrl+'/20231125220409665027.png'" mode="scaleToFill"/>
</view>
<view v-html="data.description" v-show="isOpen"></view>
</view>
</view>
</template>
<script>
export default {
name: "Coupons",
props: {
data: Object,
radioModel: {
type: Boolean,
default: false
},
checked: {
type: Boolean,
default: false
}
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
isOpen: false
}
},
methods: {
changeRules() {
this.isOpen = !this.isOpen
},
goGoods() {
uni.switchTab({url:'/pages/home/landMark'})
// this.$global.navToGoods(this.data.productId)
},
selectCoupon() {
if (!this.radioModel) return
this.$emit('change', this.data.id)
}
}
}
</script>
<style scoped lang="less">
.components-coupons {
width: 686rpx;
box-sizing: border-box;
border: 2rpx solid #FF564A;
border-radius: 16rpx;
overflow: hidden;
image {
vertical-align: middle;
}
.coupons__cover {
width: 100%;
height: 300rpx;
}
.coupons__section {
width: 100%;
box-sizing: border-box;
padding: 18rpx 20rpx 16rpx 16rpx;
font-size: 32rpx;
line-height: 1;
text {
color: #EA1C1C;
font-weight: bold;
}
.coupons__tag {
display: flex;
justify-content: center;
align-items: center;
width: 120rpx;
height: 52rpx;
box-sizing: border-box;
border-radius: 8rpx;
border: 2px solid #0DC5C5;
color: #0DC5C5;
font-size: 32rpx;
line-height: 1;
}
.coupons__tag-expire {
border: 2rpx solid #BFBFBF;
color: #999999;
}
}
.coupons__rules {
padding: 0 20rpx 20rpx 16rpx;
.coupons__rules-title {
color: #999999;
font-size: 28rpx;
image {
width: 26rpx;
height: 26rpx;
margin-left: 6rpx;
}
.open {
transform: rotate(180deg);
}
}
}
}
</style>
+128
View File
@@ -0,0 +1,128 @@
<template>
<view class="popup-coupons">
<view class="popup-box">
<view class="popup-title bold tc">选择优惠券</view>
<SubSection :current="current" :can-use="canUse" :not-use="notUse" radioModel @change="changeNav"/>
<view class="list-box">
<view style="margin-bottom: 20rpx" v-for="(item,index) in list" :key="index">
<Coupons :data="item" radioModel @change="selectCoupon"/>
</view>
<view class="tc" v-if="list.length===0">
<image class="zero-coupons" :src="webUrl+'/20231201201733142658.png'" mode="scaleToFill"/>
</view>
</view>
</view>
<button disabled></button>
<view class="btn-done bold flex jc-center ai-center" :class="{'btn-disabled':current===1}" @click="setCoupon" v-if="current===0">确定
</view>
</view>
</template>
<script>
import SubSection from "@/components/SubSection.vue"
import Coupons from '@/components/Coupons.vue'
export default {
name: 'CouponsPopup',
components: {SubSection, Coupons},
props: {
twoList: {
type: Object,
default: {}
}
},
computed: {
list() {
let temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable']
return this.$global.deepClone(temp)
},
canUse() {
return this.twoList['usable'].length
},
notUse() {
return this.twoList['unusable'].length
}
},
watch: {
current() {
this.selectCoupon(this.couponId)
}
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
current: 0,
couponId: 0
}
},
mounted() {
this.couponId = uni.getStorageSync('couponId') || 0
this.selectCoupon(this.couponId)
},
methods: {
changeNav(index) {
this.current = index
},
selectCoupon(id) {
const isCancel = this.couponId === id
this.couponId = isCancel ? 0 : id
this.list?.forEach(item => {
if (!isCancel) {
item.checked = id === item.id
} else {
item.checked = false
}
})
},
setCoupon() {
if (this.current === 1) return
// if (this.couponId !== 0) {
uni.setStorageSync('couponId', this.couponId)
// }
this.$emit('close')
}
}
}
</script>
<style scoped lang="less">
.popup-coupons {
.popup-box {
padding: 34rpx 32rpx;
}
.popup-title {
margin-bottom: 20rpx;
color: #333333;
font-size: 36rpx;
line-height: 52rpx;
}
.list-box {
max-height: 640rpx;
margin-top: 32rpx;
overflow-y: auto;
}
.btn-done {
width: 100%;
height: 80rpx;
background: #FF564A;
color: #FFFFFF;
font-size: 36rpx;
}
.btn-disabled {
background: #BFBFBF;
}
.zero-coupons {
width: 400rpx;
height: 366rpx;
vertical-align: middle;
}
}
</style>
-4
View File
@@ -65,9 +65,6 @@ export default {
data: function() { data: function() {
return {}; return {};
}, },
mounted: function() {
console.log(this);
},
methods: { methods: {
previewImg:function(imgUrl){ previewImg:function(imgUrl){
uni.previewImage({ uni.previewImage({
@@ -107,7 +104,6 @@ export default {
getCheckedValue: function() { getCheckedValue: function() {
let productAttr = this.attr.productAttr; let productAttr = this.attr.productAttr;
let value = []; let value = [];
// console.log(productAttr)
for (let i = 0; i < productAttr.length; i++) { for (let i = 0; i < productAttr.length; i++) {
for (let j = 0; j < productAttr[i].attrValueArr.length; j++) { for (let j = 0; j < productAttr[i].attrValueArr.length; j++) {
if (productAttr[i].index === j) { if (productAttr[i].index === j) {
+73
View File
@@ -0,0 +1,73 @@
<script>
export default {
name: "SubSection",
props: {
current: { // 当前选中
type: Number,
default: 0
},
canUse: { // 可用
type: [String, Number],
default: 0
},
notUse: { // 不可用
type: [String, Number],
default: 0
},
radioModel: {
type: Boolean,
default: false
},
},
data() {
return {
index: 0
}
},
mounted() {
this.index = this.current
},
methods: {
change(index) {
this.index = index
this.$emit('change', index)
}
}
}
</script>
<template>
<view class="sub-section flex">
<view class="sub-section__item flex jc-center ai-center" :class="{'sub-section__active':index===0}"
@click="change(0)">
可使用 ({{ canUse }})
</view>
<view class="sub-section__item flex jc-center ai-center" :class="{'sub-section__active':index===1}"
@click="change(1)">
{{radioModel?'不可用':'已到期'}} ({{ notUse }})
</view>
</view>
</template>
<style scoped lang="less">
.sub-section {
width: 686rpx;
height: 80rpx;
box-sizing: border-box;
border: 2rpx solid #FF564A;
border-radius: 4rpx;
font-size: 32rpx;
.sub-section__item {
width: 50%;
background: #FFFFFF;
color: #333333;
font-weight: bold;
}
.sub-section__active {
background: #FF564A;
color: #FFFFFF;
}
}
</style>
+201 -21
View File
@@ -19,29 +19,68 @@
@up="upCallback" @down="downCallback" @init="mescrollInit" @emptyclick="emptyClick"> @up="upCallback" @down="downCallback" @init="mescrollInit" @emptyclick="emptyClick">
<view class="fixed-box"> <view class="fixed-box">
<view class="line-location flex ai-center" v-if="location"> <view class="line-location flex ai-center">
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image> <image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
<text class="bold">当前定位{{ location }}</text> <text class="bold" v-if="location">当前定位{{ location }}</text>
<!-- @click="select(location)"--> <view style="color:#f66" @click="reload()" v-else>定位失败
<image :src="webUrl+'/20231215213824297278.png'" mode="scaleToFill"/>
</view>
</view> </view>
<image class="banner" :src="banner.icon" mode="scaleToFill" v-if="banner" <image class="banner" :src="banner.icon" mode="scaleToFill" v-if="banner"
@click="$global.commonJump(banner.url)"/> @click="$global.commonJump(banner.url)"/>
<view class="top-box" v-if="listTop.length"> <!-- <view class="top-box" v-if="listTop.length">-->
<view class="tips">特别推荐</view> <!-- <view class="tips">特别推荐</view>-->
<view class="top-list custom-list flex ai-center"> <!-- <view class="top-list custom-list flex ai-center">-->
<view class="item" v-for="(item,index) in listTop" :key="index" @click="select(item)"> <!-- <view class="item" v-for="(item,index) in listTop" :key="index" @click="select(item)">-->
<view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view> <!-- <view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view>-->
<view class="has-goods" v-if="type>0 && type<6&& item.hasShop===0">暂无店铺</view> <!-- <view class="has-goods" v-if="type>0 && type<6&& item.hasShop===0">暂无店铺</view>-->
<image :src="item.icon" mode="scaleToFill"></image> <!-- <image :src="item.icon" mode="scaleToFill"></image>-->
<view class="one-t">{{ item.cityName }}</view> <!-- <view class="one-t">{{ item.cityName }}</view>-->
</view> <!-- </view>-->
</view> <!-- </view>-->
</view> <!-- </view>-->
</view> </view>
<view class="province-name">{{ provinceName }}</view> <!--9-2 推荐信息-->
<view class="recommendInfo" v-if="recommendInfo && type<2">
<template v-if="(type===0 && recommendInfo.hotelList) || (type===1 && recommendInfo.productList)">
<view class="red-border-title">{{ recommendInfo.title }}</view>
<image class="bg-custom" :src="recommendInfo.backgroundImage" mode="scaleToFill"/>
<scroll-view class="scroll-box flex" enable-flex scroll-x>
<!-- :style="{'backgroundImage':`url(${recommendInfo.backgroundImage})`}"-->
<view class="item flex-0 flex flex-col jc-between ai-center"
v-for="(item,index) in recommendInfo.hotelList"
:key="index" v-if="type===0" @click="goStore(item.hotelId)">
<image class="cover" :src="item.hotelImage" mode="scaleToFill"/>
<image class="logo" :src="item.hotelLogo" mode="scaleToFill"/>
<view style="width: 100%">
<view class="name tc one-t">{{ item.hotelName }}</view>
<rich-text class="text tc one-t" :nodes="item.hotelText"/>
</view>
</view>
<view class="item flex-0 flex flex-col jc-between ai-center"
v-for="(item,index) in recommendInfo.productList" :key="index" v-if="type===1"
@click="$global.navToGoods(item.productId)">
<image class="cover" :src="item.productImage" mode="scaleToFill"/>
<image class="logo" :src="item.merLogo" mode="scaleToFill"/>
<view style="width: 100%">
<view class="name tc one-t">{{ item.productName }}</view>
<rich-text class="text tc one-t" :nodes="item.productText"/>
</view>
</view>
</scroll-view>
</template>
</view>
<!-- province-name-->
<view class="red-border-title" style="margin-left: 38rpx;">{{ provinceName }}</view>
<view class="group-list custom-list flex flex-wrap"> <view class="group-list custom-list flex flex-wrap">
<view class="item" v-for="(item, index) in listCity" :key="index" @click="select(item)"> <view class="item" v-for="(item, index) in listCity" :key="index" @click="select(item)">
<view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view> <view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view>
@@ -102,7 +141,8 @@ export default {
keyword: "", keyword: "",
type: null, type: null,
location: "", location: "",
banner: {} banner: {},
recommendInfo: null, // 推荐信息
}; };
}, },
onLoad(options) { onLoad(options) {
@@ -114,11 +154,50 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
reload() {
uni.getSetting({
success(res) {
if (res.authSetting['scope.userLocation']) {
} else {
uni.showModal({
title: '提示',
content: '当前定位未开启,请点击确定手动开启定位',
duration: 5000,
success(result) {
if (result.confirm) {
uni.openSetting({
success(openRes) {
if (openRes.authSetting['scope.userLocation']) {
} else {
uni.showToast({
title: '你拒绝了授权,无法继续',
icon: 'none'
})
}
}
})
} else if (result.cancel) {
uni.showToast({
title: '你拒绝了授权,无法获取定位信息',
icon: 'none'
})
}
}
})
}
}
})
},
async getMapData() { async getMapData() {
const map = await getLocation(); const map = await getLocation();
const {latitude, longitude} = map[1]; if (map) {
const address = await getCurAddress(latitude, longitude); const {latitude, longitude} = map[1];
this.location = address[1].data.result.ad_info.city; const address = await getCurAddress(latitude, longitude);
this.location = address[1].data.result.ad_info.city;
}
}, },
init() { init() {
@@ -130,6 +209,7 @@ export default {
this.listTop = this.listGroup[0].top; this.listTop = this.listGroup[0].top;
this.listCity = this.listGroup[0].city; this.listCity = this.listGroup[0].city;
this.provinceName = this.listGroup[0].label; this.provinceName = this.listGroup[0].label;
this.recommendInfo = this.listGroup[0].recommendInfo
this.banner = { this.banner = {
icon: this.listGroup[0].icon, icon: this.listGroup[0].icon,
url: this.listGroup[0].uniappUrl url: this.listGroup[0].uniappUrl
@@ -143,6 +223,7 @@ export default {
this.listTop = this.listGroup[index].top; this.listTop = this.listGroup[index].top;
this.listCity = this.listGroup[index].city; this.listCity = this.listGroup[index].city;
this.provinceName = this.listGroup[index].label; this.provinceName = this.listGroup[index].label;
this.recommendInfo = this.listGroup[index].recommendInfo
this.banner = { this.banner = {
icon: this.listGroup[index].icon, icon: this.listGroup[index].icon,
url: this.listGroup[index].uniappUrl url: this.listGroup[index].uniappUrl
@@ -195,7 +276,13 @@ export default {
uni.navigateBack() uni.navigateBack()
break; break;
} }
} },
goStore(id) {
uni.navigateTo({
url: "/pagesInn/inn/innHome?id=" + id
})
},
} }
}; };
</script> </script>
@@ -307,8 +394,22 @@ export default {
margin-left: 161rpx; margin-left: 161rpx;
margin-top: 110rpx; margin-top: 110rpx;
.red-border-title {
display: inline-flex;
align-items: center;
box-sizing: border-box;
margin: 18rpx 0;
padding: 8rpx 0 0 8rpx;
border-left: 6rpx solid #FD574B;
color: #262626;
font-size: 30rpx;
line-height: 30rpx;
font-weight: bold;
vertical-align: bottom;
}
.fixed-box { .fixed-box {
padding: 32rpx 0 44rpx 38rpx; padding: 32rpx 0 0 38rpx;
.line-location { .line-location {
font-size: 28rpx; font-size: 28rpx;
@@ -338,6 +439,77 @@ export default {
} }
} }
.recommendInfo {
position: relative;
margin-left: 38rpx;
.scroll-box {
position: relative;
width: 520rpx;
height: 314rpx;
box-sizing: border-box;
padding: 70rpx 20rpx 0 20rpx;
border-radius: 20rpx;
background-repeat: no-repeat;
background-size: 520rpx 314rpx;
}
.item {
position: relative;
width: 136rpx;
height: 220rpx;
margin-right: 28rpx;
border-radius: 8rpx;
background: linear-gradient(180deg, #08255D 0%, #6FA2FF 100%);
color: #FFFFFF;
line-height: 1;
//overflow: hidden;
image {
vertical-align: middle;
}
.cover {
width: 136rpx;
height: 136rpx;
border-radius: 8rpx;
}
.logo {
position: absolute;
left: 68rpx;
top: 136rpx;
transform: translate(-50%, -50%);
width: 40rpx;
height: 40rpx;
border-radius: 50%;
}
.name {
padding-bottom: 10rpx;
font-size: 24rpx;
}
.text {
padding-bottom: 10rpx;
font-size: 16rpx;
}
}
.item::after {
content: '';
position: absolute;
right: -14rpx;
top: 26rpx;
width: 2rpx;
height: 172rpx;
background: #D2E0E8;
}
.item:last-child::after{
display: none;
}
}
.province-name { .province-name {
margin: 0 38rpx 24rpx; margin: 0 38rpx 24rpx;
font-size: 28rpx; font-size: 28rpx;
@@ -366,5 +538,13 @@ export default {
} }
} }
} }
.bg-custom {
position: absolute;
left: 0;
top: 74rpx;
width: 520rpx;
height: 314rpx;
}
} }
</style> </style>
+22 -3
View File
@@ -1,11 +1,30 @@
// export const VUE_APP_API_URL = "https://shop.xdd618.com/api"; // export const VUE_APP_API_URL = "https://shop.xdd618.com/api";
export const VUE_APP_API_URL = "https://www.xdd618.com/api"; // export const VUE_APP_API_URL = "https://www.xdd618.com/api";
// export const SERVICE_API_URL = "https://service-test.xdd618.com/api"; // export const SERVICE_API_URL = "https://service-test.xdd618.com/api";
export const SERVICE_API_URL = "https://service.xdd618.com/api"; // export const SERVICE_API_URL = "https://service.xdd618.com/api";
// export const SOCKET_URL = "wss://service-test.xdd618.com/ws"; // export const SOCKET_URL = "wss://service-test.xdd618.com/ws";
export const SOCKET_URL = "wss://service.xdd618.com/ws"; // export const SOCKET_URL = "wss://service.xdd618.com/ws";
const NODE_ENV = process.env.VUE_APP_ENV || 'development'
let BASE_URL = ''
let SERVICE_URL = ''
let SERVICE_WS_URL = ''
if (NODE_ENV === 'development' || NODE_ENV === 'test') {
BASE_URL = 'https://shop.xdd618.com/api'
SERVICE_URL = 'https://service-test.xdd618.com/api'
SERVICE_WS_URL = 'wss://service-test.xdd618.com/ws'
}
if (NODE_ENV === 'prod') {
BASE_URL = 'https://www.xdd618.com/api'
SERVICE_URL = 'https://service.xdd618.com/api'
SERVICE_WS_URL = 'wss://service.xdd618.com/ws'
}
export const VUE_APP_API_URL = BASE_URL
export const SERVICE_API_URL = SERVICE_URL
export const SOCKET_URL = SERVICE_WS_URL
export const VUE_APP_RESOURCES_URL = "https://www.xdd618.com/api/file/pic"; export const VUE_APP_RESOURCES_URL = "https://www.xdd618.com/api/file/pic";
export const STATIC_RESOURCE_URL = "https://resource.xdd618.com/image" export const STATIC_RESOURCE_URL = "https://resource.xdd618.com/image"
+27 -4
View File
@@ -77,7 +77,7 @@
"miniapp-color-thief": "^1.0.5", "miniapp-color-thief": "^1.0.5",
"number-precision": "^1.5.2", "number-precision": "^1.5.2",
"regenerator-runtime": "^0.12.1", "regenerator-runtime": "^0.12.1",
"uview-ui": "2.0.31", "uview-ui": "2.0.36",
"vconsole": "^3.14.6", "vconsole": "^3.14.6",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-ydui": "^1.2.6", "vue-ydui": "^1.2.6",
@@ -117,7 +117,30 @@
"resolutions": { "resolutions": {
"@babel/runtime": "~7.17.9" "@babel/runtime": "~7.17.9"
}, },
"uni-app": { "uni-app": {
"scripts": {} "scripts": {
} "mp-weixin-test": {
"title": "微信小程序(Test环境)",
"env": {
"UNI_PLATFORM": "mp-weixin",
"VUE_APP_ENV": "test",
"UNI_OUTPUT_DIR": "dist"
},
"define": {
"CUSTOM-CONST": true
}
},
"mp-weixin": {
"title": "微信小程序(生产环境)",
"env": {
"UNI_PLATFORM": "mp-weixin",
"VUE_APP_ENV": "prod",
"UNI_OUTPUT_DIR": "dist"
},
"define": {
"CUSTOM-CONST": true
}
}
}
}
} }
+17 -28
View File
@@ -254,18 +254,6 @@
"navigationBarTitleText": "用户vip" "navigationBarTitleText": "用户vip"
} }
}, },
{
"path": "pages/user/coupon/UserCoupon/index",
"style": {
"navigationBarTitleText": "优惠券"
}
},
{
"path": "pages/user/coupon/GetCoupon/index",
"style": {
"navigationBarTitleText": "领取优惠券"
}
},
{ {
"path": "pages/user/promotion/UserCash/index", "path": "pages/user/promotion/UserCash/index",
"style": { "style": {
@@ -743,6 +731,12 @@
"navigationBarTitleText": "绑定手机号" "navigationBarTitleText": "绑定手机号"
} }
}, },
{
"path": "views/myCoupons",
"style": {
"navigationBarTitleText": "我的优惠券"
}
},
{ {
"path": "views/payPassword", "path": "views/payPassword",
"style": { "style": {
@@ -920,32 +914,27 @@
] ]
}, },
"condition": { "condition": {
"current": 3, "current": 1,
"list": [ "list": [
{ {
"name": "商品详情", "name": "商品详情",
"path": "pages/shop/GoodsCon/index", "path": "pages/shop/GoodsCon/index",
"query": "id=303&from=famous" "query": "id=289"
},
{
"name": "v9-2",
"path": "pages/order/OrderSubmission/index",
"query": "id=2539"
}, },
{ {
"name": "DEBUG", "name": "DEBUG",
"path": "pkg_product/views/healthList", "path": "pages/shop/GoodsCon/index",
"query": "id=32" "query": "id=466"
},
{
"name": "节日",
"path": "pkg_product/views/festival",
"query": ""
}, },
{ {
"name": "非遗", "name": "非遗",
"path": "pkg_product/views/heritage", "path": "pages/order/OrderSubmission/index",
"query": "" "query": "id=2597"
},
{
"name": "地标好物",
"path": "pages/home/landMark",
"query": ""
} }
] ]
} }
-1
View File
@@ -28,7 +28,6 @@ export default {
if (memCityName.length) { if (memCityName.length) {
this.cityName = memCityName; this.cityName = memCityName;
uni.removeStorageSync("cityName") uni.removeStorageSync("cityName")
console.log("memCityName if")
this.search(); this.search();
} }
}, },
+40 -9
View File
@@ -66,10 +66,10 @@
</view> </view>
<!-- 快捷跳转块v4end --> <!-- 快捷跳转块v4end -->
<!-- <view style="padding-bottom:20rpx;background: #fff;">--> <!-- <view style="padding-bottom:20rpx;background: #fff;">-->
<!-- 转盘--> <!-- 转盘-->
<!-- <image class="home-luck" :src="`${webUrl}/20220519145845818243.png`" mode="scaleToFill" @click="goLuck"></image>--> <!-- <image class="home-luck" :src="`${webUrl}/20220519145845818243.png`" mode="scaleToFill" @click="goLuck"></image>-->
<!-- </view>--> <!-- </view>-->
<!-- 伴手礼精品 --> <!-- 伴手礼精品 -->
<!-- <view class="wrapper hot" v-if="likeInfo.length > 0">--> <!-- <view class="wrapper hot" v-if="likeInfo.length > 0">-->
@@ -244,7 +244,7 @@
<!-- v9 老用户弹窗 --> <!-- v9 老用户弹窗 -->
<u-popup :show="isOldUser" mode="center" bgColor="transparent"> <u-popup :show="isOldUser" mode="center" bgColor="transparent">
<view class="popup-old-user flex flex-col ai-center"> <view class="popup-old-user flex flex-col ai-center">
<image class="main" :src="oldUserPopup.image" mode="scaleToFill" @click="$global.commonJump(oldUserPopup.url)"/> <image class="main" :src="oldUserPopup.image" mode="scaleToFill" @click="tapOld()"/>
<view class="icon-box flex jc-center ai-center" @click="changeOldPopup(false)"> <view class="icon-box flex jc-center ai-center" @click="changeOldPopup(false)">
<image :src="webUrl+'/20230608112219219303.png'" mode="scaleToFill"/> <image :src="webUrl+'/20230608112219219303.png'" mode="scaleToFill"/>
</view> </view>
@@ -314,7 +314,7 @@ import hxNavbar from "@/components/hx-navbar/hx-navbar.vue"
import imgBox from '@/components/imageTypeSet/imagebox.vue' import imgBox from '@/components/imageTypeSet/imagebox.vue'
import LsSwiper from '@/components//ls-swiper/index.vue' import LsSwiper from '@/components//ls-swiper/index.vue'
import {noticeDetail, noticeList} from "@/api/user"; import {getCouponReceive, noticeDetail, noticeList} from "@/api/user";
import {getHomeData, getShareImage} from '@/api/public'; import {getHomeData, getShareImage} from '@/api/public';
import {getHomeHotelList} from "@/api/inn.js"; import {getHomeHotelList} from "@/api/inn.js";
import {getProducts} from "@/api/store"; import {getProducts} from "@/api/store";
@@ -457,6 +457,7 @@ export default {
}, },
onLoad: function (options) { onLoad: function (options) {
that = this; that = this;
this.init();
getShareImage().then(({data}) => this.shareAppImg = data); getShareImage().then(({data}) => this.shareAppImg = data);
uni.getSystemInfo({ uni.getSystemInfo({
success: (e) => { success: (e) => {
@@ -522,7 +523,6 @@ export default {
this.getUnreadMsgList(); this.getUnreadMsgList();
} }
this.init();
//获取团购商品 //获取团购商品
this.getGroupGoods(); this.getGroupGoods();
}, },
@@ -668,6 +668,7 @@ export default {
msgConfirm: function () { msgConfirm: function () {
that.$refs.popup.close(); that.$refs.popup.close();
}, },
getHotelList: function () { getHotelList: function () {
let that = this; let that = this;
@@ -829,6 +830,36 @@ export default {
goFestival() { goFestival() {
uni.navigateTo({url: '/pkg_product/views/festival'}) uni.navigateTo({url: '/pkg_product/views/festival'})
},
tapOld() {
this.isOldUser =false
const {type, text, jumpTime, pageLevel, url, params, couponId} = this.oldUserPopup
if (couponId != null) {
getCouponReceive(couponId).then(res => {
if (res.status === 200) {
uni.showToast({
title: text,
icon: 'none',
success: () => {
}
})
}
}).catch((err) => {
uni.showToast({
title: err.data.msg+'',
icon: 'none',
duration:3000
})
})
}
// type 1-定时跳转,2-点击跳转,3-不跳转
if (type === 1) {
setTimeout(() => {
this.$global.levelJump(pageLevel, url, params)
}, jumpTime * 1000)
} else if (type === 2) {
this.$global.levelJump(pageLevel, url, params)
}
} }
} }
}; };
@@ -1735,8 +1766,8 @@ export default {
.swiper { .swiper {
position: absolute; position: absolute;
left:20rpx; left: 20rpx;
bottom:20rpx; bottom: 20rpx;
width: 296rpx; width: 296rpx;
height: 72rpx; height: 72rpx;
overflow: hidden; overflow: hidden;
+2 -1
View File
@@ -27,7 +27,7 @@ export default {
return 718 / (this.mapData?.mapImageWidth || 1); return 718 / (this.mapData?.mapImageWidth || 1);
} }
}, },
onShow() { onLoad() {
this.getNavList(); this.getNavList();
}, },
onReachBottom() { onReachBottom() {
@@ -91,6 +91,7 @@ export default {
<view class="search-box flex ai-center"> <view class="search-box flex ai-center">
<input type="text" v-model="keyword" placeholder="搜索商品" placeholder-style="color:#999" <input type="text" v-model="keyword" placeholder="搜索商品" placeholder-style="color:#999"
@confirm="search()"/> @confirm="search()"/>
<image :src="webUrl+'/20231223183627184005.png'" mode="scaleToFill" style="width:30rpx;height:30rpx"/>
</view> </view>
<view class="map-box"> <view class="map-box">
+1 -1
View File
@@ -193,7 +193,7 @@
<view class="conter" style="width: auto !important;">{{ force2Decimal(orderInfo.totalPrice) }}</view> <view class="conter" style="width: auto !important;">{{ force2Decimal(orderInfo.totalPrice) }}</view>
</view> </view>
<view class="item acea-row row-between" v-if="orderInfo.couponPrice > 0"> <view class="item acea-row row-between" v-if="orderInfo.couponPrice > 0">
<view>优惠券抵扣</view> <view class="flex-0">优惠券抵扣</view>
<view class="conter">-{{ force2Decimal(orderInfo.couponPrice) }}</view> <view class="conter">-{{ force2Decimal(orderInfo.couponPrice) }}</view>
</view> </view>
<view class="item acea-row row-between" v-if="orderInfo.useIntegral > 0"> <view class="item acea-row row-between" v-if="orderInfo.useIntegral > 0">
+64 -184
View File
@@ -1,31 +1,6 @@
<template> <template>
<view class="order-submission" style="padding: 30rpx;"> <view class="order-submission" style="padding: 30rpx;">
<view class="allAddress" style="background-color: #f6f6f6;"> <view class="allAddress" style="background-color: #f6f6f6;">
<!-- <view class="nav acea-row">
<view
class="item font-color-red"
:class="shipping_type === 0 ? 'on' : 'on2'"
@click="addressType(0)"
v-if="systemStore"
></view>
<view
class="item font-color-red"
:class="shipping_type === 1 ? 'on' : 'on2'"
@click="addressType(1)"
v-if="storeSelfMention"
></view>
</view> -->
<!-- <view class="acea-row" style="padding-left: 28rpx;">
<view v-if="systemStore" class="item" style="position: relative;" @click="addressType(0)">
<text :class="shipping_type === 0 ? 'on' :''" class="goods-detail-title">送货上门</text>
<text v-if="shipping_type === 0" class="pink-dot"></text>
</view>
<view v-if="storeSelfMention" class="item" style="position: relative;margin-left: 40rpx;" @click="addressType(1)">
<text :class="shipping_type === 1 ? 'on' :''" class="goods-detail-title">到店自取</text>
<text v-if="shipping_type === 1" class="pink-dot"></text>
</view>
</view> -->
<view <view
class="address acea-row row-middle" class="address acea-row row-middle"
@@ -42,7 +17,7 @@
<text class="phone">{{ addressInfo.phone }}</text> <text class="phone">{{ addressInfo.phone }}</text>
</view> </view>
<view> <view>
<!-- <text class="default font-color-lightred" v-if="addressInfo.isDefault">[默认]</text> -->
{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.detail }} {{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.detail }}
</view> </view>
</view> </view>
@@ -74,42 +49,8 @@
<OrderGoods :evaluate="0" :cartInfo="orderGroupInfo.cartInfo" title="商品列表"></OrderGoods> <OrderGoods :evaluate="0" :cartInfo="orderGroupInfo.cartInfo" title="商品列表"></OrderGoods>
<view class="wrapper" style="margin: 30rpx 0;border-radius: 16rpx;"> <view class="wrapper" style="margin: 30rpx 0;border-radius: 16rpx;">
<!-- 优惠券开始 -->
<!-- <view class="item acea-row row-between-wrapper" @click="couponTap" v-if="deduction === false">
<view>优惠券</view>
<view class="discount">
{{ usableCoupon.couponTitle || "请选择" }}
<text class="iconfont icon-jiantou"></text>
</view>
</view> -->
<!-- 优惠券结束 -->
<!-- 积分抵扣开始 -->
<!-- <view
class="item acea-row row-between-wrapper"
v-if="deduction === false && enableIntegral === true"
>
<view>积分抵扣</view>
<view class="discount">
<view class="select-btn">
<view class="checkbox-wrapper">
<checkbox-group @change="changeUseIntegral">
<label class="well-check">
<text class="integral">
当前积分
<text class="num font-color-red">{{ userInfo.integral || 0 }}</text>
</text>
<checkbox value="true" :checked="useIntegral ? true : false"></checkbox>
</label>
</checkbox-group>
</view>
</view>
</view>
</view> -->
<!-- 积分抵扣结束 -->
<view class="item acea-row row-between-wrapper" style="flex-wrap: nowrap;" v-if="shipping_type === 0"> <view class="item acea-row row-between-wrapper" style="flex-wrap: nowrap;" v-if="shipping_type === 0">
<view class="acea-row row-middle" style="flex-wrap: nowrap;"> <view class="acea-row row-middle" style="flex-wrap: nowrap;">
@@ -117,13 +58,6 @@
mode=""></image> mode=""></image>
<text class="">快递费用</text> <text class="">快递费用</text>
</view> </view>
<!-- <view class="discount">
{{
orderGroupInfo.priceGroup.storePostage > 0
? force2Decimal(orderGroupInfo.priceGroup.storePostage)
: (orderPrice.payPostage>0?force2Decimal(orderPrice.payPostage):"免运费")
}}
</view> -->
<view class="discount" style="width: auto !important;"> <view class="discount" style="width: auto !important;">
{{ orderPrice.payPostage > 0 ? force2Decimal(orderPrice.payPostage) : "免运费" }} {{ orderPrice.payPostage > 0 ? force2Decimal(orderPrice.payPostage) : "免运费" }}
</view> </view>
@@ -148,7 +82,7 @@
mode=""></image> mode=""></image>
<text class="">备注信息150字以内)</text> <text class="">备注信息150字以内)</text>
</view> </view>
<textarea v-model="mark" ></textarea> <textarea v-model="mark"></textarea>
</view> </view>
</view> </view>
<view class="wrapper" style="margin: 30rpx 0;border-radius: 16rpx;"> <view class="wrapper" style="margin: 30rpx 0;border-radius: 16rpx;">
@@ -237,6 +171,25 @@
<view class="money">-{{ force2Decimal(orderPrice.deductionPrice) }}</view> <view class="money">-{{ force2Decimal(orderPrice.deductionPrice) }}</view>
</view> </view>
</view> </view>
<view class="coupon-cell flex jc-between ai-center" @click="changeCoupons">
<view class="title">优惠券</view>
<view class="flex ai-center">
<text style="color:#999999" v-if="couponList.usable.length===0"></text>
<view class="flex ai-center" v-else>
<text style="color:#FF564A">{{ couponIndex < 0 ? '去选择' : -couponList.usable[couponIndex].couponPrice }}
</text>
<view class="iconfont icon-jiantou" style="flex-shrink: 0;"></view>
</view>
</view>
</view>
<!-- v9 优惠券开始 -->
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons">
<CouponsPopup :two-list="couponList" @close="changeCoupons" v-if="couponList.usable"/>
</u-popup>
<!-- v9 优惠券结束 -->
<view style="height:80rpx"></view> <view style="height:80rpx"></view>
<view class="footer acea-row row-between-wrapper" style="height: 80rpx;"> <view class="footer acea-row row-between-wrapper" style="height: 80rpx;">
<view style="margin-left: 30rpx;"> <view style="margin-left: 30rpx;">
@@ -248,14 +201,6 @@
</view> </view>
<view class="settlement acea-row row-middle row-center" @click="subscribePay">立即结算</view> <view class="settlement acea-row row-middle row-center" @click="subscribePay">立即结算</view>
</view> </view>
<CouponListWindow
v-on:couponchange="changecoupon($event)"
v-model="showCoupon"
:price="orderPrice.totalPrice"
:checked="usableCoupon.id"
@checked="changeCoupon"
:cartid="cartid"
></CouponListWindow>
<AddressWindow <AddressWindow
@checked="changeAddress" @checked="changeAddress"
@redirect="addressRedirect" @redirect="addressRedirect"
@@ -263,23 +208,15 @@
:checked="addressInfo.id" :checked="addressInfo.id"
ref="mychild" ref="mychild"
></AddressWindow> ></AddressWindow>
<!-- <uni-popup ref="popup" type="bottom">
<blPaymentPasswordInput hideTopBorder ref="secrity" @input="onInput" @confirm="onConfirm">
<block slot='header' style='width: 100%;'>
<view style="font-size: 36rpx;color: #8B8F99;margin: 10rpx 0;">请输入支付密码</view>
</block>
</blPaymentPasswordInput>
</uni-popup> -->
<passkeyborad :money="orderPrice.payPrice" showMoney :show="isShowPayPwdPop" ref='payPwdPop' @close="pwdPopClose" <passkeyborad :money="orderPrice.payPrice" showMoney :show="isShowPayPwdPop" ref='payPwdPop' @close="pwdPopClose"
@finish="pwdPopFinish"></passkeyborad> @finish="pwdPopFinish"></passkeyborad>
</view> </view>
</template> </template>
<script> <script>
import passkeyborad from '@/components/yzc-paykeyboard/yzc-paykeyboard' import passkeyborad from '@/components/yzc-paykeyboard/yzc-paykeyboard'
import OrderGoods from "@/components/OrderGoods"; import OrderGoods from "@/components/OrderGoods";
import CouponListWindow from "@/components/CouponListWindow";
import AddressWindow from "@/components/AddressWindow"; import AddressWindow from "@/components/AddressWindow";
import {createOrder, postOrderComputed, postOrderConfirm} from "@/api/order"; import {createOrder, postOrderComputed, postOrderConfirm} from "@/api/order";
import {mapGetters} from "vuex"; import {mapGetters} from "vuex";
@@ -287,6 +224,7 @@ import {weappPay} from "@/libs/wechat";
import {isNullOrEmpty, isWeixin} from "@/utils"; import {isNullOrEmpty, isWeixin} from "@/utils";
import blPaymentPasswordInput from '@/components/blPaymentPasswordInput.vue'; import blPaymentPasswordInput from '@/components/blPaymentPasswordInput.vue';
import uniPopup from '@/components/uni-popup/uni-popup.vue'; import uniPopup from '@/components/uni-popup/uni-popup.vue';
import CouponsPopup from "@/components/CouponsPopup.vue"
const NAME = "OrderSubmission", const NAME = "OrderSubmission",
_isWeixin = isWeixin(); _isWeixin = isWeixin();
@@ -294,11 +232,11 @@ export default {
name: NAME, name: NAME,
components: { components: {
OrderGoods, OrderGoods,
CouponListWindow,
AddressWindow, AddressWindow,
blPaymentPasswordInput, blPaymentPasswordInput,
uniPopup, uniPopup,
passkeyborad passkeyborad,
CouponsPopup
}, },
props: {}, props: {},
data: function () { data: function () {
@@ -312,16 +250,13 @@ export default {
enableIntegralNum: 0, enableIntegralNum: 0,
isWeixin: _isWeixin, isWeixin: _isWeixin,
pinkId: 0, pinkId: 0,
// active: _isWeixin ? "weixin" : "yue",
active: "weixin", active: "weixin",
showCoupon: false, showCoupon: false,
showAddress: false, showAddress: false,
addressInfo: {}, addressInfo: {},
couponId: 0,
orderGroupInfo: { orderGroupInfo: {
priceGroup: {} priceGroup: {}
}, },
usableCoupon: {},
addressLoaded: false, addressLoaded: false,
useIntegral: false, useIntegral: false,
orderPrice: { orderPrice: {
@@ -334,46 +269,34 @@ export default {
contactsTel: "", contactsTel: "",
storeSelfMention: 0, storeSelfMention: 0,
cartid: "", cartid: "",
payPassword: null payPassword: null,
// v9-2
couponList: {},
couponId: 0,
couponIndex: -1,
show: false
}; };
}, },
computed: mapGetters(["userInfo", "storeItems"]), computed: mapGetters(["userInfo", "storeItems"]),
watch: { watch: {
useIntegral() { useIntegral() {
this.computedPrice(); this.computedPrice('useIntegral');
}, },
// $yroute(n) {
// if (n.name === NAME){
// this.getCartInfo();
// // this.$store.dispatch("getUser", true);
// }
// },
shipping_type() { shipping_type() {
this.computedPrice(); this.computedPrice('shipping_type');
},
couponId() {
this.couponIndex = this.couponList['usable']?.findIndex(item => item.id === this.couponId)
this.computedPrice('couponId')
} }
}, },
// mounted: function() {
// let that = this;
// // this.$store.dispatch("getUser", true);
// that.getCartInfo();
// console.log(that.$yroute);
// if (that.$yroute.query.pinkid !== undefined) {
// that.pinkId = that.$yroute.query.pinkid;
// }
// if (that.$yroute.query.id !== undefined) {
// that.cartid = that.$yroute.query.id;
// console.log(that.cartid)
// }
// },
onLoad: function () { onLoad: function () {
//获取用户信息
// this.$store.dispatch("getUser", true);
let that = this; let that = this;
uni.$on('chooseAddress', (res) => { uni.$on('chooseAddress', (res) => {
console.log('监听到选择收货地址:' + JSON.stringify(res)); console.log('监听到选择收货地址:' + JSON.stringify(res));
that.addressInfo = res; that.addressInfo = res;
//地址切换也要重新计算一下 //地址切换也要重新计算一下
that.computedPrice(); that.computedPrice('onLoad chooseAddress');
}) })
that.getCartInfo(); that.getCartInfo();
console.log(that.$yroute); console.log(that.$yroute);
@@ -404,27 +327,13 @@ export default {
force2Decimal(value) { force2Decimal(value) {
return this.$force2Decimal(value); return this.$force2Decimal(value);
}, },
addressType: function (index) { computedPrice(f) {
if (index && !this.systemStore.id) { console.log(f)
uni.showToast({
title: "暂无门店信息,您无法选择到店自提!",
icon: "none",
duration: 2000
});
return;
}
this.shipping_type = index;
},
changeUseIntegral: function (e) {
// this.computedPrice();
this.useIntegral = e.mp.detail.value[0];
},
computedPrice() {
let shipping_type = this.shipping_type; let shipping_type = this.shipping_type;
postOrderComputed(this.orderGroupInfo.orderKey, { postOrderComputed(this.orderGroupInfo.orderKey, {
addressId: this.addressInfo.id, addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0, useIntegral: this.useIntegral ? 1 : 0,
couponId: this.usableCoupon.id || 0, couponId: this.couponId || 0,
shipping_type: parseInt(shipping_type) + 1 shipping_type: parseInt(shipping_type) + 1
}).then(res => { }).then(res => {
const data = res.data; const data = res.data;
@@ -456,11 +365,12 @@ export default {
that.offlinePayStatus = res.data.offline_pay_status; that.offlinePayStatus = res.data.offline_pay_status;
that.orderGroupInfo = res.data; that.orderGroupInfo = res.data;
that.deduction = res.data.deduction; that.deduction = res.data.deduction;
that.usableCoupon = res.data.usableCoupon || {}; that.couponList = res.data.couponList
that.addressInfo = res.data.addressInfo || {}; that.addressInfo = res.data.addressInfo || {};
that.systemStore = res.data.systemStore || {}; that.systemStore = res.data.systemStore || {};
that.storeSelfMention = res.data.storeSelfMention; that.storeSelfMention = res.data.storeSelfMention;
that.computedPrice(); that.couponId = uni.getStorageSync('couponId') || 0
that.computedPrice()
}) })
.catch(err => { .catch(err => {
uni.showToast({ uni.showToast({
@@ -471,13 +381,6 @@ export default {
}); });
}, },
addressTap: function () { addressTap: function () {
// this.showAddress = true;
// if (!this.addressLoaded) {
// this.addressLoaded = true;
// this.$refs.mychild.getAddressList();
// }
//改用跳转页面方式 //改用跳转页面方式
this.$yrouter.push({ this.$yrouter.push({
path: "/pages/user/address/AddressManagement/index", path: "/pages/user/address/AddressManagement/index",
@@ -485,34 +388,18 @@ export default {
choosMode: 1 choosMode: 1
} }
}); });
}, },
addressRedirect() { addressRedirect() {
this.addressLoaded = false; this.addressLoaded = false;
this.showAddress = false; this.showAddress = false;
}, },
couponTap: function () {
this.showCoupon = true;
},
changeCoupon: function (coupon) {
if (!coupon) {
this.usableCoupon = {
couponTitle: "不使用优惠券",
id: 0
};
} else {
this.usableCoupon = coupon;
}
this.computedPrice();
},
payItem: function (index) { payItem: function (index) {
this.active = index; this.active = index;
}, },
changeAddress(addressInfo) { changeAddress(addressInfo) {
this.addressInfo = addressInfo; this.addressInfo = addressInfo;
//地址切换也要重新计算一下 //地址切换也要重新计算一下
this.computedPrice(); this.computedPrice('changeAddress');
}, },
pwdPopClose() { pwdPopClose() {
this.isShowPayPwdPop = false; this.isShowPayPwdPop = false;
@@ -527,17 +414,10 @@ export default {
}, },
// 支付密码输入确认 // 支付密码输入确认
onConfirm(e) { onConfirm(e) {
let password = e.value; this.payPassword = e.value;
// if(password)
console.log('password:' + password);
this.payPassword = password;
this.$refs.popup.close();//关闭支付密码弹窗 this.$refs.popup.close();//关闭支付密码弹窗
this.$refs.secrity.clear();//清空支付密码 this.$refs.secrity.clear();//清空支付密码
this.createOrder(true); this.createOrder(true);
}, },
subscribePay() { subscribePay() {
uni.requestSubscribeMessage({ uni.requestSubscribeMessage({
@@ -629,7 +509,7 @@ export default {
phone: this.contactsTel, phone: this.contactsTel,
addressId: this.addressInfo.id, addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0, useIntegral: this.useIntegral ? 1 : 0,
couponId: this.usableCoupon.id || 0, couponId: this.couponId || 0,
payType: this.active, payType: this.active,
pinkId: this.pinkId, pinkId: this.pinkId,
seckillId: this.orderGroupInfo.seckill_id, seckillId: this.orderGroupInfo.seckill_id,
@@ -646,6 +526,7 @@ export default {
if (this.active == 'yue') { if (this.active == 'yue') {
params.passwordPay = this.payPassword; params.passwordPay = this.payPassword;
} }
uni.removeStorageSync('couponId')
var that = this; var that = this;
createOrder(this.orderGroupInfo.orderKey, params) createOrder(this.orderGroupInfo.orderKey, params)
@@ -731,12 +612,6 @@ export default {
}); });
}); });
break; break;
// 下面为原先微信支付方式,
// pay(data.result.jsConfig).finally(() => {
// this.$yrouter.replace({
// path: "/pages/order/OrderDetails/index" ,query: { id: data.result.orderId}
// });
// });
} }
}) })
.catch(err => { .catch(err => {
@@ -755,12 +630,18 @@ export default {
that.$refs.payPwdPop.clear();//清空支付密码 that.$refs.payPwdPop.clear();//清空支付密码
that.$refs.payPwdPop.close();//关闭支付密码弹窗 that.$refs.payPwdPop.close();//关闭支付密码弹窗
}); });
} },
// v9-2
changeCoupons() {
if (this.couponList.usable.length === 0) return
this.show = !this.show
this.couponId = uni.getStorageSync('couponId') || 0
},
} }
}; };
</script> </script>
<style scoped lang="less">
<style scoped lang="less">
.pink-dot { .pink-dot {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
@@ -829,15 +710,6 @@ export default {
.order-submission .allAddress { .order-submission .allAddress {
width: 100%; width: 100%;
// background-image: linear-gradient(to bottom, #00c17b 0%, #00c17b 100%);
// background-image: -webkit-linear-gradient(
// to bottom,
// #00c17b 0%,
// #00c17b 100%
// );
// background-image: -moz-linear-gradient(to bottom, #00c17b 0%, #00c17b 100%);
// padding-top: 1 * 100rpx;
// padding-top: 40rpx;
} }
.order-submission .allAddress .nav { .order-submission .allAddress .nav {
@@ -922,4 +794,12 @@ export default {
.order-submission .wrapper .item .discount input::placeholder { .order-submission .wrapper .item .discount input::placeholder {
color: #ccc; color: #ccc;
} }
.coupon-cell {
margin-top: 12rpx;
padding: 30rpx;
border-radius: 16rpx;
background-color: #FFFFFF;
font-size: 24rpx;
}
</style> </style>
+57 -84
View File
@@ -198,39 +198,27 @@
<text v-if="tempName">{{ tempName }}</text> <text v-if="tempName">{{ tempName }}</text>
<text>销量:{{ dayInfo.sales }}{{ dayInfo.unitName }}</text> <text>销量:{{ dayInfo.sales }}{{ dayInfo.unitName }}</text>
</view> </view>
<!-- 优惠券选择开始 -->
<!-- <view
class="coupon acea-row row-between-wrapper"
@click="couponTap"
v-if="couponList.length"
>
<text class="hide line1 acea-row">
<text>优惠券</text>
<text
class="activity"
v-for="(item, couponListEq) in couponList"
:key="couponListEq"
>{{ item.use_min_price }}{{ item.coupon_price }}</text>
</text>
<view class="iconfont icon-jiantou"></view>
</view> -->
<!-- 优惠券选择结束 -->
</view> </view>
<!-- 已选规格开始 --> <!-- v9 优惠券开始 -->
<!-- <view class="attribute acea-row row-between-wrapper" @click="selecAttrTap">--> <u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons()">
<!-- <view>--> <CouponsPopup :two-list="couponList" @close="changeCoupons"/>
<!-- <text>{{ attrTxt }}</text>--> </u-popup>
<!-- <text class="atterTxt">{{ attrValue }}</text>--> <!-- v9 优惠券结束 -->
<!-- </view>-->
<!-- <view class="iconfont icon-jiantou"></view>-->
<!-- </view>-->
<!-- 已选规格结束 -->
<!-- v6服务项目开始 --> <!-- v6服务项目开始 -->
<view class="service-section goods-section" v-if="storeInfo && storeInfo.isTickets!=1"> <view class="service-section goods-section" v-if="storeInfo && storeInfo.isTickets!=1">
<view class="cell flex jc-between ai-center" @click="changeCoupons()" v-if="couponList['usable'].length>0">
<view>
<text class="coupon-label tc" v-for="(item,index) in couponList.usable" :key="index" v-if="index<2">
{{ item.couponTitle }}
</text>
</view>
<view class="value">优惠详情
<uni-icons type="right" size="13" color="#707070"></uni-icons>
</view>
</view>
<view class="cell flex jc-between ai-center" @click="selecAttrTap"> <view class="cell flex jc-between ai-center" @click="selecAttrTap">
<view class="flex ai-center"> <view class="flex ai-center">
<view class="after-title">规格</view> <view class="after-title">规格</view>
@@ -459,7 +447,7 @@
</view> </view>
</view> </view>
</view> </view>
<CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop> <!-- <CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop>-->
<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"/> <ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"/>
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus" <StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
:posterData="posterData" :goodId="id"></StorePoster> :posterData="posterData" :goodId="id"></StorePoster>
@@ -488,13 +476,12 @@
<script> <script>
import ProductConSwiper from "@/components/ProductConSwiper"; import ProductConSwiper from "@/components/ProductConSwiper";
import UserEvaluation from "@/components/UserEvaluation"; import UserEvaluation from "@/components/UserEvaluation";
import CouponPop from "@/components/CouponPop";
import ProductWindow from "@/components/ProductWindow"; import ProductWindow from "@/components/ProductWindow";
import StorePoster from "@/components/StorePoster"; import StorePoster from "@/components/StorePoster";
import ShareInfo from "@/components/ShareInfo"; import ShareInfo from "@/components/ShareInfo";
import CountDown from "@/components/CountDown"; import CountDown from "@/components/CountDown";
import {getCartCount, getProductCode, getProductDetail, postCartAdd} from "@/api/store"; import {getCartCount, getProductCode, getProductDetail, postCartAdd} from "@/api/store";
import {getCollectAdd, getCollectDel, getCoupon, userBindParent} from "@/api/user"; import {userBindParent} from "@/api/user";
import {handleQrCode, isWeixin} from "@/utils"; import {handleQrCode, isWeixin} from "@/utils";
import {getHomeData} from "@/api/public"; import {getHomeData} from "@/api/public";
import {getDailyGoods, getPreSale, getYxStoreSeckill} from "@/api/goods"; import {getDailyGoods, getPreSale, getYxStoreSeckill} from "@/api/goods";
@@ -503,6 +490,8 @@ import {diffDay, formatDateTime} from "@/utils/index";
import {getCurAddress, getLocation, getUrlParam} from "@/utils/common.js"; import {getCurAddress, getLocation, getUrlParam} from "@/utils/common.js";
import cookie from "@/utils/store/cookie"; import cookie from "@/utils/store/cookie";
import {famousGoodsShareImage, secKillGoodsShareImage} from "@/api/share"; import {famousGoodsShareImage, secKillGoodsShareImage} from "@/api/share";
import CouponsPopup from "@/components/CouponsPopup.vue"
import { formatContent } from '@/utils/util.js'
export default { export default {
name: "GoodsCon", name: "GoodsCon",
@@ -510,10 +499,10 @@ export default {
CountDown, CountDown,
ProductConSwiper, ProductConSwiper,
UserEvaluation, UserEvaluation,
CouponPop,
ProductWindow, ProductWindow,
StorePoster, StorePoster,
ShareInfo ShareInfo,
CouponsPopup
}, },
data: function () { data: function () {
return { return {
@@ -549,7 +538,7 @@ export default {
killInfo: {}, killInfo: {},
dayInfo: {}, dayInfo: {},
storeInfo: {}, storeInfo: {},
couponList: [], couponList: {},
attrTxt: "请选择", attrTxt: "请选择",
attrValue: "", attrValue: "",
cart_num: 1, //购买数量 cart_num: 1, //购买数量
@@ -581,7 +570,9 @@ export default {
isWenwan: 0, isWenwan: 0,
postAddress: null, postAddress: null,
exSliceEnd: 3, exSliceEnd: 3,
webUrl: this.$VUE_APP_RESOURCES_URL webUrl: this.$VUE_APP_RESOURCES_URL,
// v9-2
show: false,
}; };
}, },
computed: mapGetters(["isLogin", "location", "userInfo"]), computed: mapGetters(["isLogin", "location", "userInfo"]),
@@ -597,12 +588,18 @@ export default {
params += `&activityId=${this.activityId}` params += `&activityId=${this.activityId}`
} }
if (result.status === 200) { if (result?.status === 200) {
resolve({ resolve({
title: this.storeInfo.storeName, title: this.storeInfo.storeName,
path: '/pages/shop/GoodsCon/index' + params, path: '/pages/shop/GoodsCon/index' + params,
imageUrl: result.data imageUrl: result.data
}) })
} else {
resolve({
title: this.storeInfo.storeName,
path: '/pages/shop/GoodsCon/index' + params,
imageUrl: this.storeInfo.image
})
} }
}) })
}, },
@@ -610,6 +607,7 @@ export default {
// test data // test data
console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync()); console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync());
console.log("getEnterOptionsSync", uni.getEnterOptionsSync()); console.log("getEnterOptionsSync", uni.getEnterOptionsSync());
uni.removeStorageSync('couponId')
let url = handleQrCode(); let url = handleQrCode();
if (url && url.productId) { if (url && url.productId) {
@@ -950,6 +948,10 @@ export default {
if (this.$deviceType == "app") { if (this.$deviceType == "app") {
from.from = "app"; from.from = "app";
} }
if (that.source === 'kill') {
from.seckillId = that.activityId
}
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
mask: true mask: true
@@ -961,7 +963,7 @@ export default {
// /\<img/gi, // /\<img/gi,
// '<img style="display:block;max-width:100%;height:auto;"' // '<img style="display:block;max-width:100%;height:auto;"'
// ); // );
that.$set(that, "storeInfo", res.data.storeInfo); that.$set(that, "storeInfo", formatContent(res.data.storeInfo));
that.isWenwan = res.data.isWenwan; that.isWenwan = res.data.isWenwan;
// 给 attr 赋值,将请求回来的规格赋值给 attr // 给 attr 赋值,将请求回来的规格赋值给 attr
@@ -969,7 +971,11 @@ export default {
that.$set(that.attr, "productAttr", res.data.productAttr); that.$set(that.attr, "productAttr", res.data.productAttr);
that.$set(that, "productValue", res.data.productValue); that.$set(that, "productValue", res.data.productValue);
} }
that.attr.defaultSku = res.data.defaultSku
that.attr.defaultSkuIndex = res.data.defaultSkuIndex
res.data.couponList['unusable']?.map(item => item.status = 2)
that.$set(that, 'couponList', res.data.couponList)
that.$set(that, "replyCount", res.data.replyCount); that.$set(that, "replyCount", res.data.replyCount);
that.$set(that, "replyChance", res.data.replyChance); that.$set(that, "replyChance", res.data.replyChance);
that.reply = res.data.reply ? [res.data.reply] : []; that.reply = res.data.reply ? [res.data.reply] : [];
@@ -1028,11 +1034,14 @@ export default {
let productAttr = this.attr.productAttr; let productAttr = this.attr.productAttr;
let value = []; let value = [];
for (let i = 0; i < productAttr.length; i++) { for (let i = 0; i < productAttr.length; i++) {
this.$set(productAttr[i], "index", 0); this.$set(productAttr[i], "index", this.attr.defaultSkuIndex[i]);
value.push(productAttr[i].attrValueArr[0]); value.push(productAttr[i].attrValueArr[1]);
} }
//sort();排序函数:数字-英文-汉字; //sort();排序函数:数字-英文-汉字;
let productSelect = this.productValue[value.sort().join(",")]; // let productSelect = this.productValue[value.sort().join(",")];
const skuKey = this.attr.defaultSku?.join(',')
let productSelect = this.productValue[skuKey]
if (productSelect && productAttr.length) { if (productSelect && productAttr.length) {
this.$set( this.$set(
this.attr.productSelect, this.attr.productSelect,
@@ -1045,7 +1054,8 @@ export default {
this.$set(this.attr.productSelect, "stock", productSelect.stock); this.$set(this.attr.productSelect, "stock", productSelect.stock);
this.$set(this.attr.productSelect, "unique", productSelect.unique); this.$set(this.attr.productSelect, "unique", productSelect.unique);
this.$set(this.attr.productSelect, "cart_num", 1); this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "attrValue", value.sort().join(",")); // this.$set(this, "attrValue", value.sort().join(","));
this.$set(this, "attrValue", skuKey);
this.$set(this, "attrTxt", "已选择"); this.$set(this, "attrTxt", "已选择");
} else if (!productSelect && productAttr.length) { } else if (!productSelect && productAttr.length) {
this.$set( this.$set(
@@ -1121,33 +1131,7 @@ export default {
let value = opt.value === undefined ? "" : opt.value; let value = opt.value === undefined ? "" : opt.value;
this[action] && this[action](value); this[action] && this[action](value);
}, },
//打开优惠券插件;
couponTap: function () {
let that = this;
that.coupons();
that.coupon.coupon = true;
},
changecoupon: function (msg) {
this.coupon.coupon = msg;
this.coupons();
},
currentcoupon: function (res) {
let that = this;
that.coupon.coupon = false;
that.$set(that.coupon.list[res], "is_use", true);
},
//可领取优惠券接口;
coupons: function () {
let that = this,
q = {
page: 1,
limit: 20
};
getCoupon(q).then(res => {
that.$set(that, "couponList", res.data || []);
that.$set(that.coupon, "list", res.data);
});
},
//打开属性插件; //打开属性插件;
selecAttrTap: function () { selecAttrTap: function () {
this.attr.cartAttr = true; this.attr.cartAttr = true;
@@ -1184,21 +1168,6 @@ export default {
this.$set(this, "attrTxt", "请选择"); this.$set(this, "attrTxt", "请选择");
} }
}, },
//收藏商品
setCollect: function () {
let that = this,
id = that.storeInfo.id,
category = "product";
if (that.storeInfo.userCollect) {
getCollectDel(id, category).then(function () {
that.storeInfo.userCollect = !that.storeInfo.userCollect;
});
} else {
getCollectAdd(id, category).then(function () {
that.storeInfo.userCollect = !that.storeInfo.userCollect;
});
}
},
// 点击加入购物车按钮 // 点击加入购物车按钮
joinCart: function () { joinCart: function () {
if (this.isOpen === true && this.attr.productSelect.stock === 0) return; if (this.isOpen === true && this.attr.productSelect.stock === 0) return;
@@ -1322,7 +1291,11 @@ export default {
}, },
listenerActionClose: function () { listenerActionClose: function () {
this.posters = false; this.posters = false;
} },
// v9-2
changeCoupons() {
this.show = !this.show
},
} }
}; };
</script> </script>
+8 -28
View File
@@ -1,16 +1,5 @@
<template> <template>
<view class="shoppingCart"> <view class="shoppingCart">
<!-- <hx-navbar
title="购物车"
:fixed="true"
:back="false"
:left-slot="false"
:right-slot="false"
color="#ffffff"
statusBarFontColor="#ffffff"
:bgImgHeight="bgImgHeight"
:background-color="[254,82,97]"
:background-img="webUrl+'/20200729160752671638.png'"/> -->
<hx-navbar <hx-navbar
title="购物车" title="购物车"
:fixed="true" :fixed="true"
@@ -31,28 +20,11 @@
<view> <view>
<text class="num" style="color: #666666;">{{ count }}件商品</text> <text class="num" style="color: #666666;">{{ count }}件商品</text>
</view> </view>
<!-- <view
v-if="cartList.valid.length > 0"
class="administrate acea-row row-center-wrapper font-color-white"
@click="manage"
>{{ footerswitch ? '取消' : '管理' }}</view> -->
<view class="top-delete-btn acea-row row-middle" @click="delgoods"> <view class="top-delete-btn acea-row row-middle" @click="delgoods">
<image class="delete-icon" :src="webUrl+'/20210806133058078099.png'" mode=""></image> <image class="delete-icon" :src="webUrl+'/20210806133058078099.png'" mode=""></image>
</view> </view>
</view> </view>
<view style="border-top: 1px solid #f5f5f5" v-if="$store.getters.token||userInfo.uid"> <view style="border-top: 1px solid #f5f5f5" v-if="$store.getters.token||userInfo.uid">
<!-- <view style="margin-top: 80rpx;" v-if="$store.getters.token||userInfo.uid"> -->
<!-- <view class="labelNav acea-row row-around row-middle">
<view class="item">
<text class="iconfont icon-xuanzhong"></text>100%正品保证
</view>
<view class="item">
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
</view>
<view class="item">
<text class="iconfont icon-xuanzhong"></text>售后无忧
</view>
</view> -->
<view v-if="validList.length > 0 || cartList.invalid.length > 0"> <view v-if="validList.length > 0 || cartList.invalid.length > 0">
<view class="list"> <view class="list">
@@ -529,6 +501,14 @@ export default {
plus: function (index) { plus: function (index) {
let that = this; let that = this;
let list = that.cartList.valid[index]; let list = that.cartList.valid[index];
if (list.cartNum + 1 > list.trueStock) {
uni.showToast({
title: '该商品库存不足,无法继续增加',
icon: 'none'
})
return
}
list.cartNum++; list.cartNum++;
if (list.attrInfo) { if (list.attrInfo) {
if (list.cartNum >= list.attrInfo.stock) { if (list.cartNum >= list.attrInfo.stock) {
+13 -36
View File
@@ -218,6 +218,14 @@
</view> </view>
<view class="serviceList acea-row row-middle"> <view class="serviceList acea-row row-middle">
<view class="item" @click="goCoupons()">
<view class="pictrue">
<image :src="webUrl+'/20231130162907823563.png'"/>
</view>
<view class="cell">我的优惠券</view>
<text class="iconfont icon-jiantou"></text>
</view>
<view class="item" @click="goGroupManage()"> <view class="item" @click="goGroupManage()">
<view class="pictrue"> <view class="pictrue">
<image :src="webUrl+'/20221010165555111608.png'"/> <image :src="webUrl+'/20221010165555111608.png'"/>
@@ -280,39 +288,13 @@
<view class="cell">客服历史会话</view> <view class="cell">客服历史会话</view>
<text class="iconfont icon-jiantou"></text> <text class="iconfont icon-jiantou"></text>
</view> </view>
<!-- <template v-for="(item, MyMenusIndex) in MyMenus">
<view
class="item"
:key="MyMenusIndex"
@click="goPages(MyMenusIndex)"
>
<view class="pictrue">
<image :src="item.pic" />
</view>
<view class="cell">{{ item.name }}</view>
<text class="iconfont icon-jiantou"></text>
</view>
</template> -->
<!-- <view class="item" @click="goPages2()">
<view class="pictrue"></view>
<view class="cell">hexiao</view>
<text class="iconfont icon-jiantou"></text>
</view> -->
</view> </view>
</view> </view>
<!-- 我的服务结束 --> <!-- 我的服务结束 -->
</view> </view>
<!-- <view class="by">
<view>
<text class="by-text">www.yixiang.co提供技术支持</text>
</view>
</view> -->
</view> </view>
<uni-popup ref="popup" type="center"> <uni-popup ref="popup" type="center">
<!-- <view class="acea-row row-column row-middle" style="position: relative;background-color: #fff;width: 440rpx;border-radius: 20rpx;"> -->
<view class="acea-row row-column row-middle" <view class="acea-row row-column row-middle"
style="position: relative;background-color: #fff;border-radius: 20rpx;"> style="position: relative;background-color: #fff;border-radius: 20rpx;">
<view class="acea-row row-center" style="border-radius: 50%;margin-top: -52rpx;background-color: #fff;"> <view class="acea-row row-center" style="border-radius: 50%;margin-top: -52rpx;background-color: #fff;">
@@ -626,6 +608,11 @@ export default {
// } // }
// }) // })
}, },
goCoupons() {
uni.navigateTo({
url: '/pkg_user/views/myCoupons'
})
},
goGroupManage() { goGroupManage() {
this.$yrouter.push("/pages/user/promotion/UserPromotion/index"); this.$yrouter.push("/pages/user/promotion/UserPromotion/index");
}, },
@@ -924,16 +911,6 @@ page {
color: #ffffff; color: #ffffff;
} }
.by {
text-align: center;
padding: 30rpx 0;
}
.by-text {
text-align: center;
font-size: 24rpx;
}
.header { .header {
background: linear-gradient(90deg, rgba(254, 150, 107, 1) 0%, rgba(255, 88, 75, 1) 100%); background: linear-gradient(90deg, rgba(254, 150, 107, 1) 0%, rgba(255, 88, 75, 1) 100%);
} }
+2 -1
View File
@@ -25,7 +25,8 @@
<view class="article-box"> <view class="article-box">
<view class="line-location flex ai-center"> <view class="line-location flex ai-center">
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image> <image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
<text class="bold" @click="goCity">当前城市{{ cityName }}</text> <!-- @click="goCity"-->
<text class="bold">当前城市{{ cityName }}</text>
</view> </view>
<scroll-view class="list flex flex-wrap" :style="{'height':listHeight}" :enable-flex="true" <scroll-view class="list flex flex-wrap" :style="{'height':listHeight}" :enable-flex="true"
+105
View File
@@ -0,0 +1,105 @@
<template>
<view class="pkg-user-coupons">
<SubSection :current="current" :can-use="canUse" :not-use="notUse" @change="changeNav"/>
<Coupons class="coupons" :data="item" v-for="(item,index) in list" :key="index"/>
<image class="zero-coupons" :src="webUrl+'/20231201201733142658.png'" mode="scaleToFill" v-if="list.length===0"/>
<!-- <view>-->
<!-- <button @tap="startRecord">开始录音</button>-->
<!-- <button @tap="endRecord">停止录音</button>-->
<!-- <button @tap="playVoice">播放录音</button>-->
<!-- </view>-->
</view>
</template>
<script>
import SubSection from "@/components/SubSection.vue";
import Coupons from "@/components/Coupons.vue";
import {getCouponsUser} from "@/api/user";
const recorderManager = uni.getRecorderManager();
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
export default {
name: "myCoupons",
components: {SubSection, Coupons},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
voicePath: '',
current: 0,
canUse: 0,
notUse: 0,
list: []
}
},
onLoad() {
// let self = this;
// recorderManager.onStop(function (res) {
// console.log('recorder stop' + JSON.stringify(res));
// self.voicePath = res.tempFilePath;
// });
this.fetchList(1)
this.fetchList(2)
},
methods: {
startRecord() {
console.log('开始录音');
recorderManager.start();
},
endRecord() {
console.log('录音结束');
recorderManager.stop();
},
playVoice() {
console.log('播放录音');
if (this.voicePath) {
innerAudioContext.src = this.voicePath;
innerAudioContext.play();
}
},
changeNav(index) {
this.current = index
this.fetchList(index + 1)
},
fetchList(type) {
// type 1-可使用,2-已到期
getCouponsUser(type).then(({data}) => {
if (this.current + 1 === type) this.list = data
this.list?.forEach(item => {
item.isOpen = false
})
if (type === 1) this.canUse = data.length
if (type === 2) this.notUse = data.length
})
},
}
}
</script>
<style lang="less" scoped>
.pkg-user-coupons {
padding: 40rpx 32rpx;
/deep/ .components-coupons {
margin-top: 32rpx;
}
.zero-coupons {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 400rpx;
height: 366rpx;
vertical-align: middle;
}
}
</style>
+2 -2
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 www.uviewui.com Copyright (c) 2023 www.uviewui.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
+6 -1
View File
@@ -1,4 +1,9 @@
## 2.0.342022-09-25 ## 2.0.362023-03-27
# uView2.0重磅发布,利剑出鞘,一统江湖
1. 重构`deepClone` & `deepMerge`方法
2. 其他优化
## 2.0.342022-09-24
# uView2.0重磅发布,利剑出鞘,一统江湖 # uView2.0重磅发布,利剑出鞘,一统江湖
1. `u-input``u-textarea`增加`ignoreCompositionEvent`属性 1. `u-input``u-textarea`增加`ignoreCompositionEvent`属性
@@ -211,7 +211,7 @@ export default {
let style = {}; let style = {};
if (this.color) { if (this.color) {
// 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色 // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
style.color = this.plain ? this.color : "#EEEEEE"; style.color = this.plain ? this.color : "white";
if (!this.plain) { if (!this.plain) {
// 非镂空,背景色使用自定义的颜色 // 非镂空,背景色使用自定义的颜色
style["background-color"] = this.color; style["background-color"] = this.color;
@@ -8,7 +8,7 @@
class="u-calendar-header__subtitle" class="u-calendar-header__subtitle"
v-if="showSubtitle" v-if="showSubtitle"
>{{ subtitle }}</text> >{{ subtitle }}</text>
<!-- <view class="u-calendar-header__weekdays"> <view class="u-calendar-header__weekdays">
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
@@ -16,7 +16,7 @@
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
<text class="u-calendar-header__weekdays__weekday"></text> <text class="u-calendar-header__weekdays__weekday"></text>
</view> --> </view>
</view> </view>
</template> </template>
@@ -10,37 +10,15 @@
<view class="u-calendar-month__days__day" v-for="(item1, index1) in item.date" :key="index1" <view class="u-calendar-month__days__day" v-for="(item1, index1) in item.date" :key="index1"
:style="[dayStyle(index, index1, item1)]" @tap="clickHandler(index, index1, item1)" :style="[dayStyle(index, index1, item1)]" @tap="clickHandler(index, index1, item1)"
:class="[item1.selected && 'u-calendar-month__days__day__select--selected']"> :class="[item1.selected && 'u-calendar-month__days__day__select--selected']">
<view class="u-calendar-month__days__day__select flex-column" > <view class="u-calendar-month__days__day__select" :style="[daySelectStyle(index, index1, item1)]">
<view class="u-calendar-month__days__day__select__info day-info" <text class="u-calendar-month__days__day__select__info"
:class="[item1.disabled && 'u-calendar-month__days__day__select__info--disabled']" :class="[item1.disabled && 'u-calendar-month__days__day__select__info--disabled']"
:style="[daySelectStyle(index, index1, item1)]"> :style="[textStyle(item1)]">{{ item1.day }}</text>
<text :style="[textStyle(item1)]"> <text v-if="getBottomInfo(index, index1, item1)"
{{ item1.day }}
</text>
</view>
<!-- <text v-if="getBottomInfo(index, index1, item1)"
class="u-calendar-month__days__day__select__buttom-info" class="u-calendar-month__days__day__select__buttom-info"
:class="[item1.disabled && 'u-calendar-month__days__day__select__buttom-info--disabled']" :class="[item1.disabled && 'u-calendar-month__days__day__select__buttom-info--disabled']"
:style="[textStyle(item1)]">{{ getBottomInfo(index, index1, item1) }}</text> --> :style="[textStyle(item1)]">{{ getBottomInfo(index, index1, item1) }}</text>
<!-- <text v-if="item1.dot" class="u-calendar-month__days__day__select__dot"></text> --> <text v-if="item1.dot" class="u-calendar-month__days__day__select__dot"></text>
<view class="align-center justify-around" v-if="getBottomInfo(index, index1, item1).text">
<text
class="font-sm mr-1"
:class="[
{'grey--text' : getBottomInfo(index, index1, item1).status == 0 },
{'error--text' : getBottomInfo(index, index1, item1).status == 1 },
{'success--text' : getBottomInfo(index, index1, item1).status == 2 }]"
>
{{ getBottomInfo(index, index1, item1).text }}
</text>
<text
v-if="item1.dot"
:class="[
{'grey' : getBottomInfo(index, index1, item1).status == 0 },
{'error' : getBottomInfo(index, index1, item1).status == 1 },
{'success' : getBottomInfo(index, index1, item1).status == 2 }]"
class="day_dot" ></text>
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -203,11 +181,10 @@
if (this.mode === 'single') { if (this.mode === 'single') {
if (date === this.selected[0]) { if (date === this.selected[0]) {
// 因为需要对nvue的兼容,只能这么写,无法缩写,也无法通过类名控制等等 // 因为需要对nvue的兼容,只能这么写,无法缩写,也无法通过类名控制等等
style.borderRadius = '50%' style.borderTopLeftRadius = '3px'
// style.borderTopLeftRadius = '3px' style.borderBottomLeftRadius = '3px'
// style.borderBottomLeftRadius = '3px' style.borderTopRightRadius = '3px'
// style.borderTopRightRadius = '3px' style.borderBottomRightRadius = '3px'
// style.borderBottomRightRadius = '3px'
} }
} else if (this.mode === 'range') { } else if (this.mode === 'range') {
if (this.selected.length >= 2) { if (this.selected.length >= 2) {
@@ -373,7 +350,6 @@
}, },
// 点击某一个日期 // 点击某一个日期
clickHandler(index1, index2, item) { clickHandler(index1, index2, item) {
this.$emit('select', item)
if (this.readonly) { if (this.readonly) {
return; return;
} }
@@ -478,25 +454,7 @@
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../libs/css/components.scss"; @import "../../libs/css/components.scss";
.align-center{
flex-direction: row !important;
align-items: center !important;
}
.day-info{
background: #Fff;
border-radius: 50%;
height: 60rpx;
width: 60rpx;
line-height: 60rpx;
}
.flex-column{
flex-direction: column !important
}
.day_dot{
width: 30rpx;
height: 15rpx;
border-radius: 15rpx;
}
.u-calendar-month-wrapper { .u-calendar-month-wrapper {
margin-top: 4px; margin-top: 4px;
} }
@@ -38,7 +38,6 @@
:maxMonth="monthNum" :maxMonth="monthNum"
:readonly="readonly" :readonly="readonly"
:maxRange="maxRange" :maxRange="maxRange"
@select="$emit('select', $event)"
:rangePrompt="rangePrompt" :rangePrompt="rangePrompt"
:showRangePrompt="showRangePrompt" :showRangePrompt="showRangePrompt"
:allowSameDay="allowSameDay" :allowSameDay="allowSameDay"
@@ -30,7 +30,7 @@
<slot name="right-icon" v-if="$slots['right-icon']"> <slot name="right-icon" v-if="$slots['right-icon']">
</slot> </slot>
<u-icon v-else :name="rightIcon" :custom-style="rightIconStyle" :color="disabled ? '#c8c9cc' : 'info'" <u-icon v-else :name="rightIcon" :custom-style="rightIconStyle" :color="disabled ? '#c8c9cc' : 'info'"
:size="size === 'large' ? 36 : 32"></u-icon> :size="size === 'large' ? 18 : 16"></u-icon>
</view> </view>
</view> </view>
<u-line v-if="border"></u-line> <u-line v-if="border"></u-line>
@@ -210,5 +210,5 @@ export default {
'uicon-man-delete': '\ue61a', 'uicon-man-delete': '\ue61a',
'uicon-man-delete-fill': '\ue66a', 'uicon-man-delete-fill': '\ue66a',
'uicon-zh': '\ue70a', 'uicon-zh': '\ue70a',
'uicon-en': '\ue692', 'uicon-en': '\ue692'
} }
@@ -23,13 +23,13 @@
v-if="label !== ''" v-if="label !== ''"
class="u-icon__label" class="u-icon__label"
:style="{ :style="{
color: labelColor, color: labelColor,
fontSize: $u.addUnit(labelSize), fontSize: $u.addUnit(labelSize),
marginLeft: labelPos == 'right' ? $u.addUnit(space) : 0, marginLeft: labelPos == 'right' ? $u.addUnit(space) : 0,
marginTop: labelPos == 'bottom' ? $u.addUnit(space) : 0, marginTop: labelPos == 'bottom' ? $u.addUnit(space) : 0,
marginRight: labelPos == 'left' ? $u.addUnit(space) : 0, marginRight: labelPos == 'left' ? $u.addUnit(space) : 0,
marginBottom: labelPos == 'top' ? $u.addUnit(space) : 0, marginBottom: labelPos == 'top' ? $u.addUnit(space) : 0,
}" }"
>{{ label }}</text> >{{ label }}</text>
</view> </view>
</template> </template>
@@ -114,7 +114,7 @@
* @event {Function} confirm 点击确认按钮时触发 * @event {Function} confirm 点击确认按钮时触发
* @event {Function} cancel 点击取消按钮时触发 * @event {Function} cancel 点击取消按钮时触发
* @event {Function} close 点击遮罩关闭出发,closeOnClickOverlay为true有效 * @event {Function} close 点击遮罩关闭出发,closeOnClickOverlay为true有效
* @example <u-loadmore :status="status" icon-type="iconType" load-text="loadText" /> * @example <u-modal :show="true" title="title" content="content"></u-modal>
*/ */
export default { export default {
name: 'u-modal', name: 'u-modal',
@@ -146,7 +146,7 @@
}, },
// 点击遮罩 // 点击遮罩
// 从原理上来说,modal的遮罩点击,并不是真的点击到了遮罩 // 从原理上来说,modal的遮罩点击,并不是真的点击到了遮罩
// 因为modal依赖于popup的中部弹窗类型,中部弹窗比较特殊,虽然遮罩,但是为了让弹窗内容能flex居中 // 因为modal依赖于popup的中部弹窗类型,中部弹窗比较特殊,虽然遮罩,但是为了让弹窗内容能flex居中
// 多了一个透明的遮罩,此透明的遮罩会覆盖在灰色的遮罩上,所以实际上是点击不到灰色遮罩的,popup内部在 // 多了一个透明的遮罩,此透明的遮罩会覆盖在灰色的遮罩上,所以实际上是点击不到灰色遮罩的,popup内部在
// 透明遮罩的子元素做了.stop处理,所以点击内容区,也不会导致误触发 // 透明遮罩的子元素做了.stop处理,所以点击内容区,也不会导致误触发
clickHandler() { clickHandler() {
@@ -1,12 +1,5 @@
export default { export default {
props: { props: {
// 是否两行
isTwoLine: {
default: false
},
twoLineText: {
default: ''
},
// 是否开启顶部安全区适配 // 是否开启顶部安全区适配
safeAreaInsetTop: { safeAreaInsetTop: {
type: Boolean, type: Boolean,
@@ -43,17 +43,12 @@
</slot> </slot>
</view> </view>
<slot name="center"> <slot name="center">
<view class="flex-column"> <text
<text class="u-line-1 u-navbar__content__title"
class="u-line-1 u-navbar__content__title" :style="[{
:style="[{ width: $u.addUnit(titleWidth),
width: $u.addUnit(titleWidth), }, $u.addStyle(titleStyle)]"
}, $u.addStyle(titleStyle)]" >{{ title }}</text>
>{{ title }}</text>
<text class="u-line-1 u-navbar__content__title font-xs grey--text" v-if="isTwoLine">
{{ twoLineText }}
</text>
</view>
</slot> </slot>
<view <view
class="u-navbar__content__right" class="u-navbar__content__right"
@@ -34,7 +34,7 @@
<u-icon <u-icon
name="close" name="close"
color="#909399" color="#909399"
size="36" size="18"
bold bold
></u-icon> ></u-icon>
</view> </view>
@@ -103,7 +103,7 @@
}, },
// 组件选中激活时的颜色 // 组件选中激活时的颜色
elActiveColor() { elActiveColor() {
return this.activeColor ? this.activeColor : (this.parentData.activeColor ? this.parentData.activeColor : '#0052D9'); return this.activeColor ? this.activeColor : (this.parentData.activeColor ? this.parentData.activeColor : '#2979ff');
}, },
// 组件选未中激活时的颜色 // 组件选未中激活时的颜色
elInactiveColor() { elInactiveColor() {
@@ -246,7 +246,7 @@
$u-radio-square-border-radius:3px !default; $u-radio-square-border-radius:3px !default;
$u-radio-checked-color:#fff !default; $u-radio-checked-color:#fff !default;
$u-radio-checked-background-color:red !default; $u-radio-checked-background-color:red !default;
$u-radio-checked-border-color: #0052D9 !default; $u-radio-checked-border-color: #2979ff !default;
$u-radio-disabled-background-color:#ebedf0 !default; $u-radio-disabled-background-color:#ebedf0 !default;
$u-radio-disabled--checked-color:#c8c9cc !default; $u-radio-disabled--checked-color:#c8c9cc !default;
$u-radio-label-margin-left: 5px !default; $u-radio-label-margin-left: 5px !default;
@@ -10,10 +10,6 @@ export default {
icon: String, icon: String,
default: uni.$u.props.tabbarItem.icon default: uni.$u.props.tabbarItem.icon
}, },
iconSize: {
icon: String,
default: 20
},
// 右上角的角标提示信息 // 右上角的角标提示信息
badge: { badge: {
type: [String, Number, null], type: [String, Number, null],
@@ -9,7 +9,7 @@
v-if="icon" v-if="icon"
:name="icon" :name="icon"
:color="isActive? parentData.activeColor : parentData.inactiveColor" :color="isActive? parentData.activeColor : parentData.inactiveColor"
:size="iconSize" :size="20"
></u-icon> ></u-icon>
<template v-else> <template v-else>
<slot <slot
@@ -83,7 +83,7 @@ export default {
}, },
// 文字装饰,下划线,中划线等,可选值 none|underline|line-through // 文字装饰,下划线,中划线等,可选值 none|underline|line-through
decoration: { decoration: {
tepe: String, type: String,
default: uni.$u.props.text.decoration default: uni.$u.props.text.decoration
}, },
// 外边距,对象、字符串,数值形式均可 // 外边距,对象、字符串,数值形式均可
+2 -2
View File
@@ -1,5 +1,5 @@
// 此版本发布于2022-00-24 // 此版本发布于2023-03-27
const version = '2.0.34' const version = '2.0.36'
// 开发环境才提示,生产环境不会提示 // 开发环境才提示,生产环境不会提示
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
+60 -34
View File
@@ -2,8 +2,8 @@ import test from './test.js'
import { round } from './digit.js' import { round } from './digit.js'
/** /**
* @description 如果value小于min,取min;如果value大于max,取max * @description 如果value小于min,取min;如果value大于max,取max
* @param {number} min * @param {number} min
* @param {number} max * @param {number} max
* @param {number} value * @param {number} value
*/ */
function range(min = 0, max = 0, value = 0) { function range(min = 0, max = 0, value = 0) {
@@ -13,7 +13,7 @@ function range(min = 0, max = 0, value = 0) {
/** /**
* @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换 * @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换
* @param {number|string} value 用户传递值的px值 * @param {number|string} value 用户传递值的px值
* @param {boolean} unit * @param {boolean} unit
* @returns {number|string} * @returns {number|string}
*/ */
function getPx(value, unit = false) { function getPx(value, unit = false) {
@@ -41,7 +41,7 @@ function sleep(value = 30) {
} }
/** /**
* @description 运行期判断平台 * @description 运行期判断平台
* @returns {string} 返回所在平台(小写) * @returns {string} 返回所在平台(小写)
* @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台 * @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
*/ */
function os() { function os() {
@@ -49,7 +49,7 @@ function os() {
} }
/** /**
* @description 获取系统信息同步接口 * @description 获取系统信息同步接口
* @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync * @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
*/ */
function sys() { function sys() {
return uni.getSystemInfoSync() return uni.getSystemInfoSync()
@@ -179,22 +179,34 @@ function addUnit(value = 'auto', unit = uni?.$u?.config?.unit ?? 'px') {
/** /**
* @description 深度克隆 * @description 深度克隆
* @param {object} obj 需要深度克隆的对象 * @param {object} obj 需要深度克隆的对象
* @param cache 缓存
* @returns {*} 克隆后的对象或者原值(不是对象) * @returns {*} 克隆后的对象或者原值(不是对象)
*/ */
function deepClone(obj) { function deepClone(obj, cache = new WeakMap()) {
// 对常见的“非”值,直接返回原来值 if (obj === null || typeof obj !== 'object') return obj;
if ([null, undefined, NaN, false].includes(obj)) return obj if (cache.has(obj)) return cache.get(obj);
if (typeof obj !== 'object' && typeof obj !== 'function') { let clone;
// 原始类型直接返回 if (obj instanceof Date) {
return obj clone = new Date(obj.getTime());
} } else if (obj instanceof RegExp) {
const o = test.array(obj) ? [] : {} clone = new RegExp(obj);
for (const i in obj) { } else if (obj instanceof Map) {
if (obj.hasOwnProperty(i)) { clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i] } else if (obj instanceof Set) {
clone = new Set(Array.from(obj, value => deepClone(value, cache)));
} else if (Array.isArray(obj)) {
clone = obj.map(value => deepClone(value, cache));
} else if (Object.prototype.toString.call(obj) === '[object Object]') {
clone = Object.create(Object.getPrototypeOf(obj));
cache.set(obj, clone);
for (const [key, value] of Object.entries(obj)) {
clone[key] = deepClone(value, cache);
} }
} else {
clone = Object.assign({}, obj);
} }
return o cache.set(obj, clone);
return clone;
} }
/** /**
@@ -205,24 +217,27 @@ function deepClone(obj) {
*/ */
function deepMerge(target = {}, source = {}) { function deepMerge(target = {}, source = {}) {
target = deepClone(target) target = deepClone(target)
if (typeof target !== 'object' || typeof source !== 'object') return false if (typeof target !== 'object' || target === null || typeof source !== 'object' || source === null) return target;
const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target);
for (const prop in source) { for (const prop in source) {
if (!source.hasOwnProperty(prop)) continue if (!source.hasOwnProperty(prop)) continue;
if (prop in target) { const sourceValue = source[prop];
if (typeof target[prop] !== 'object') { const targetValue = merged[prop];
target[prop] = source[prop] if (sourceValue instanceof Date) {
} else if (typeof source[prop] !== 'object') { merged[prop] = new Date(sourceValue);
target[prop] = source[prop] } else if (sourceValue instanceof RegExp) {
} else if (target[prop].concat && source[prop].concat) { merged[prop] = new RegExp(sourceValue);
target[prop] = target[prop].concat(source[prop]) } else if (sourceValue instanceof Map) {
} else { merged[prop] = new Map(sourceValue);
target[prop] = deepMerge(target[prop], source[prop]) } else if (sourceValue instanceof Set) {
} merged[prop] = new Set(sourceValue);
} else if (typeof sourceValue === 'object' && sourceValue !== null) {
merged[prop] = deepMerge(targetValue, sourceValue);
} else { } else {
target[prop] = source[prop] merged[prop] = sourceValue;
} }
} }
return target return merged;
} }
/** /**
@@ -327,7 +342,7 @@ if (!String.prototype.padStart) {
/** /**
* @description 时间戳转为多久之前 * @description 时间戳转为多久之前
* @param {String|Number} timestamp 时间戳 * @param {String|Number} timestamp 时间戳
* @param {String|Boolean} format * @param {String|Boolean} format
* 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式; * 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
* 如果为布尔值false,无论什么时间,都返回多久以前的格式 * 如果为布尔值false,无论什么时间,都返回多久以前的格式
* @returns {string} 转化后的内容 * @returns {string} 转化后的内容
@@ -517,7 +532,7 @@ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparato
while (re.test(s[0])) { while (re.test(s[0])) {
s[0] = s[0].replace(re, `$1${sep}$2`) s[0] = s[0].replace(re, `$1${sep}$2`)
} }
if ((s[1] || '').length < prec) { if ((s[1] || '').length < prec) {
s[1] = s[1] || '' s[1] = s[1] || ''
s[1] += new Array(prec - s[1].length + 1).join('0') s[1] += new Array(prec - s[1].length + 1).join('0')
@@ -531,7 +546,7 @@ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparato
* 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画 * 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画
* @param {String|number} value 比如: "1s"|"100ms"|1|100 * @param {String|number} value 比如: "1s"|"100ms"|1|100
* @param {boolean} unit 提示: 如果是false 默认返回number * @param {boolean} unit 提示: 如果是false 默认返回number
* @return {string|number} * @return {string|number}
*/ */
function getDuration(value, unit = true) { function getDuration(value, unit = true) {
const valueNum = parseInt(value) const valueNum = parseInt(value)
@@ -650,6 +665,16 @@ function pages() {
return pages return pages
} }
/**
* 获取页面历史栈指定层实例
* @param back {number} [0] - 0或者负数,表示获取历史栈的哪一层,0表示获取当前页面实例,-1 表示获取上一个页面实例。默认0。
*/
function getHistoryPage(back = 0) {
const pages = getCurrentPages()
const len = pages.length
return pages[len - 1 + back]
}
/** /**
* @description 修改uView内置属性值 * @description 修改uView内置属性值
* @param {object} props 修改内置props属性 * @param {object} props 修改内置props属性
@@ -701,5 +726,6 @@ export default {
setProperty, setProperty,
page, page,
pages, pages,
getHistoryPage,
setConfig setConfig
} }
+107 -107
View File
@@ -4,121 +4,121 @@
*/ */
class Router { class Router {
constructor() { constructor() {
// 原始属性定义 // 原始属性定义
this.config = { this.config = {
type: 'navigateTo', type: 'navigateTo',
url: '', url: '',
delta: 1, // navigateBack页面后退时,回退的层数 delta: 1, // navigateBack页面后退时,回退的层数
params: {}, // 传递的参数 params: {}, // 传递的参数
animationType: 'pop-in', // 窗口动画,只在APP有效 animationType: 'pop-in', // 窗口动画,只在APP有效
animationDuration: 300, // 窗口动画持续时间,单位毫秒,只在APP有效 animationDuration: 300, // 窗口动画持续时间,单位毫秒,只在APP有效
intercept: false // 是否需要拦截 intercept: false // 是否需要拦截
} }
// 因为route方法是需要对外赋值给另外的对象使用,同时route内部有使用this,会导致route失去上下文 // 因为route方法是需要对外赋值给另外的对象使用,同时route内部有使用this,会导致route失去上下文
// 这里在构造函数中进行this绑定 // 这里在构造函数中进行this绑定
this.route = this.route.bind(this) this.route = this.route.bind(this)
} }
// 判断url前面是否有"/",如果没有则加上,否则无法跳转 // 判断url前面是否有"/",如果没有则加上,否则无法跳转
addRootPath(url) { addRootPath(url) {
return url[0] === '/' ? url : `/${url}` return url[0] === '/' ? url : `/${url}`
} }
// 整合路由参数 // 整合路由参数
mixinParam(url, params) { mixinParam(url, params) {
url = url && this.addRootPath(url) url = url && this.addRootPath(url)
// 使用正则匹配,主要依据是判断是否有"/","?","="等,如“/page/index/index?name=mary" // 使用正则匹配,主要依据是判断是否有"/","?","="等,如“/page/index/index?name=mary"
// 如果有url中有get参数,转换后无需带上"?" // 如果有url中有get参数,转换后无需带上"?"
let query = '' let query = ''
if (/.*\/.*\?.*=.*/.test(url)) { if (/.*\/.*\?.*=.*/.test(url)) {
// object对象转为get类型的参数 // object对象转为get类型的参数
query = uni.$u.queryParams(params, false) query = uni.$u.queryParams(params, false)
// 因为已有get参数,所以后面拼接的参数需要带上"&"隔开 // 因为已有get参数,所以后面拼接的参数需要带上"&"隔开
return url += `&${query}` return url += `&${query}`
} }
// 直接拼接参数,因为此处url中没有后面的query参数,也就没有"?/&"之类的符号 // 直接拼接参数,因为此处url中没有后面的query参数,也就没有"?/&"之类的符号
query = uni.$u.queryParams(params) query = uni.$u.queryParams(params)
return url += query return url += query
} }
// 对外的方法名称 // 对外的方法名称
async route(options = {}, params = {}) { async route(options = {}, params = {}) {
// 合并用户的配置和内部的默认配置 // 合并用户的配置和内部的默认配置
let mergeConfig = {} let mergeConfig = {}
if (typeof options === 'string') { if (typeof options === 'string') {
// 如果options为字符串,则为route(url, params)的形式 // 如果options为字符串,则为route(url, params)的形式
mergeConfig.url = this.mixinParam(options, params) mergeConfig.url = this.mixinParam(options, params)
mergeConfig.type = 'navigateTo' mergeConfig.type = 'navigateTo'
} else { } else {
mergeConfig = uni.$u.deepMerge(options, this.config) mergeConfig = uni.$u.deepMerge(this.config, options)
// 否则正常使用mergeConfig中的url和params进行拼接 // 否则正常使用mergeConfig中的url和params进行拼接
mergeConfig.url = this.mixinParam(options.url, options.params) mergeConfig.url = this.mixinParam(options.url, options.params)
} }
// 如果本次跳转的路径和本页面路径一致,不执行跳转,防止用户快速点击跳转按钮,造成多次跳转同一个页面的问题 // 如果本次跳转的路径和本页面路径一致,不执行跳转,防止用户快速点击跳转按钮,造成多次跳转同一个页面的问题
if (mergeConfig.url === uni.$u.page()) return if (mergeConfig.url === uni.$u.page()) return
if (params.intercept) { if (params.intercept) {
this.config.intercept = params.intercept this.config.intercept = params.intercept
} }
// params参数也带给拦截器 // params参数也带给拦截器
mergeConfig.params = params mergeConfig.params = params
// 合并内外部参数 // 合并内外部参数
mergeConfig = uni.$u.deepMerge(this.config, mergeConfig) mergeConfig = uni.$u.deepMerge(this.config, mergeConfig)
// 判断用户是否定义了拦截器 // 判断用户是否定义了拦截器
if (typeof uni.$u.routeIntercept === 'function') { if (typeof uni.$u.routeIntercept === 'function') {
// 定一个promise,根据用户执行resolve(true)或者resolve(false)来决定是否进行路由跳转 // 定一个promise,根据用户执行resolve(true)或者resolve(false)来决定是否进行路由跳转
const isNext = await new Promise((resolve, reject) => { const isNext = await new Promise((resolve, reject) => {
uni.$u.routeIntercept(mergeConfig, resolve) uni.$u.routeIntercept(mergeConfig, resolve)
}) })
// 如果isNext为true,则执行路由跳转 // 如果isNext为true,则执行路由跳转
isNext && this.openPage(mergeConfig) isNext && this.openPage(mergeConfig)
} else { } else {
this.openPage(mergeConfig) this.openPage(mergeConfig)
} }
} }
// 执行路由跳转 // 执行路由跳转
openPage(config) { openPage(config) {
// 解构参数 // 解构参数
const { const {
url, url,
type, type,
delta, delta,
animationType, animationType,
animationDuration animationDuration
} = config } = config
if (config.type == 'navigateTo' || config.type == 'to') { if (config.type == 'navigateTo' || config.type == 'to') {
uni.navigateTo({ uni.navigateTo({
url, url,
animationType, animationType,
animationDuration animationDuration
}) })
} }
if (config.type == 'redirectTo' || config.type == 'redirect') { if (config.type == 'redirectTo' || config.type == 'redirect') {
uni.redirectTo({ uni.redirectTo({
url url
}) })
} }
if (config.type == 'switchTab' || config.type == 'tab') { if (config.type == 'switchTab' || config.type == 'tab') {
uni.switchTab({ uni.switchTab({
url url
}) })
} }
if (config.type == 'reLaunch' || config.type == 'launch') { if (config.type == 'reLaunch' || config.type == 'launch') {
uni.reLaunch({ uni.reLaunch({
url url
}) })
} }
if (config.type == 'navigateBack' || config.type == 'back') { if (config.type == 'navigateBack' || config.type == 'back') {
uni.navigateBack({ uni.navigateBack({
delta delta
}) })
} }
} }
} }
export default (new Router()).route export default (new Router()).route
+1 -1
View File
@@ -2,7 +2,7 @@
"id": "uview-ui", "id": "uview-ui",
"name": "uview-ui", "name": "uview-ui",
"displayName": "uView2.0重磅发布,利剑出鞘,一统江湖", "displayName": "uView2.0重磅发布,利剑出鞘,一统江湖",
"version": "2.0.34", "version": "2.0.36",
"description": "uView UI已完美兼容nvue,全面的组件和便捷的工具会让您信手拈来,如鱼得水", "description": "uView UI已完美兼容nvue,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"keywords": [ "keywords": [
"uview", "uview",
+2 -2
View File
@@ -10,7 +10,7 @@ $u-border-color: #dadbde;
$u-bg-color: #f3f4f6; $u-bg-color: #f3f4f6;
$u-disabled-color: #c8c9cc; $u-disabled-color: #c8c9cc;
$u-primary: #2196F3; $u-primary: #3c9cff;
$u-primary-dark: #398ade; $u-primary-dark: #398ade;
$u-primary-disabled: #9acafc; $u-primary-disabled: #9acafc;
$u-primary-light: #ecf5ff; $u-primary-light: #ecf5ff;
@@ -20,7 +20,7 @@ $u-warning-dark: #f1a532;
$u-warning-disabled: #f9d39b; $u-warning-disabled: #f9d39b;
$u-warning-light: #fdf6ec; $u-warning-light: #fdf6ec;
$u-success: #1FCC27; $u-success: #5ac725;
$u-success-dark: #53c21d; $u-success-dark: #53c21d;
$u-success-disabled: #a9e08f; $u-success-disabled: #a9e08f;
$u-success-light: #f5fff0; $u-success-light: #f5fff0;
+73 -73
View File
@@ -7,63 +7,63 @@ const fly = new Fly()
fly.config.baseURL = VUE_APP_API_URL fly.config.baseURL = VUE_APP_API_URL
fly.interceptors.response.use( fly.interceptors.response.use(
response => { response => {
// 定时刷新access-token // 定时刷新access-token
return response; return response;
}, },
error => { error => {
if (error.toString() == 'Error: Network Error') { if (error.toString() == 'Error: Network Error') {
console.log('————————') console.log('————————')
console.log('发送请求失败', error) console.log('发送请求失败', error)
console.log('————————') console.log('————————')
handleLoginFailure(); handleLoginFailure();
return Promise.reject({ msg: "未登录", toLogin: true }); return Promise.reject({ msg: "未登录", toLogin: true });
}
if (error.status == 401) {
console.log('————————')
console.log('登录失效 401', error)
console.log('————————')
handleLoginFailure();
return Promise.reject({ msg: "未登录", toLogin: true });
}
return Promise.reject(error);
} }
if (error.status == 401) {
console.log('————————')
console.log('登录失效 401', error)
console.log('————————')
handleLoginFailure();
return Promise.reject({ msg: "未登录", toLogin: true });
}
return Promise.reject(error);
}
); );
const defaultOpt = { login: true }; const defaultOpt = { login: true };
function baseRequest(options) { function baseRequest(options) {
// 从缓存中获取 token 防止 token 失效后还会继续请求的情况 // 从缓存中获取 token 防止 token 失效后还会继续请求的情况
const token = cookie.get('login_status'); const token = cookie.get('login_status');
// 合并传参过来的 headers // 合并传参过来的 headers
// 如果接口需要登录,携带 token 去请求 // 如果接口需要登录,携带 token 去请求
options.headers = { options.headers = {
...options.headers, ...options.headers,
Authorization: "Bearer " + token Authorization: "Bearer " + token
}
// 结构请求需要的参数
const { url, params, data, login, ...option } = options
// 发起请求
return fly.request(url, params || data, {
...option
}).then(res => {
const data = res.data || {};
if (res.status !== 200) {
return Promise.reject({ msg: "请求失败", res, data });
} }
if ([401, 403].indexOf(data.status) !== -1) {
handleLoginFailure(); // 结构请求需要的参数
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true }); const { url, params, data, login, ...option } = options
} else if (data.status === 200) {
return Promise.resolve(data, res); // 发起请求
} else { return fly.request(url, params || data, {
return Promise.reject({ msg: res.data.msg, res, data }); ...option
} }).then(res => {
}); const data = res.data || {};
if (res.status !== 200) {
return Promise.reject({ msg: "请求失败", res, data });
}
if ([401, 403].indexOf(data.status) !== -1) {
handleLoginFailure();
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
} else if (data.status === 200) {
return Promise.resolve(data, res);
} else {
return Promise.reject({ msg: res.data.msg, res, data });
}
});
} }
/** /**
@@ -72,34 +72,34 @@ function baseRequest(options) {
* *
*/ */
const request = ["post", "put", "patch"].reduce((request, method) => { const request = ["post", "put", "patch"].reduce((request, method) => {
/** /**
* *
* @param url string 接口地址 * @param url string 接口地址
* @param data object get参数 * @param data object get参数
* @param options object axios 配置项 * @param options object axios 配置项
* @returns {AxiosPromise} * @returns {AxiosPromise}
*/ */
request[method] = (url, data = {}, options = {}) => { request[method] = (url, data = {}, options = {}) => {
return baseRequest( return baseRequest(
Object.assign({ url, data, method }, defaultOpt, options) Object.assign({ url, data, method }, defaultOpt, options)
); );
}; };
return request; return request;
}, {}); }, {});
["get", "delete", "head"].forEach(method => { ["get", "delete", "head"].forEach(method => {
/** /**
* *
* @param url string 接口地址 * @param url string 接口地址
* @param params object get参数 * @param params object get参数
* @param options object axios 配置项 * @param options object axios 配置项
* @returns {AxiosPromise} * @returns {AxiosPromise}
*/ */
request[method] = (url, params = {}, options = {}) => { request[method] = (url, params = {}, options = {}) => {
return baseRequest( return baseRequest(
Object.assign({ url, params, method }, defaultOpt, options) Object.assign({ url, params, method }, defaultOpt, options)
); );
}; };
}); });
export default request; export default request;
+3 -2
View File
@@ -7,8 +7,9 @@
<view class="nav-box flex jc-between ai-center"> <view class="nav-box flex jc-between ai-center">
<view class="location-box flex ai-center"> <view class="location-box flex ai-center">
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill" @click="goCity"></image> <!-- @click="goCity"-->
<text class="city-name" @click="goCity">{{ cityName }}</text> <image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
<text class="city-name">{{ cityName }}</text>
<text>当前定位</text> <text>当前定位</text>
</view> </view>
<view class="more-box flex ai-center"> <view class="more-box flex ai-center">