feat : 合并代码
This commit is contained in:
commit
62442b4798
21
api/shop.js
21
api/shop.js
@ -1,11 +1,16 @@
|
||||
export const apiArr = {
|
||||
goodsCateList: "/api/v2/wechat/commodity/cate",//商品分类列表
|
||||
getGoodsList:"/api/v2/wechat/commodity", //商品分类
|
||||
getGoodsInfo:"/api/v2/wechat/commodity/info", //商品详情
|
||||
getCar:"/api/v2/wechat/commodity/cart",//购物车
|
||||
getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
||||
addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
|
||||
deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
|
||||
updateCar:"/api/v2/wechat/commodity/cart/update",//更新购物车信息
|
||||
getUserDefAddress:"/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
|
||||
getGoodsList: "/api/v2/wechat/commodity", //商品分类
|
||||
getGoodsInfo: "/api/v2/wechat/commodity/info", //商品详情
|
||||
getCar: "/api/v2/wechat/commodity/cart",//购物车
|
||||
getCarCount: "/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
||||
addCar: "/api/v2/wechat/commodity/cart/add",//添加购物车
|
||||
deleteCar: "/api/v2/wechat/commodity/cart/delete",//删除购物车
|
||||
updateCar: "/api/v2/wechat/commodity/cart/update",//更新购物车信息
|
||||
getUserDefAddress: "/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
|
||||
createOrder: "/api/v2/wechat/commodity/order/create",//创建商品订单
|
||||
payOrder: "/api/v2/wechat/commodity/order/pay",//支付订单
|
||||
settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认
|
||||
updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改
|
||||
queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单
|
||||
}
|
||||
@ -78,6 +78,9 @@ export default {
|
||||
console.log('新市区跟旧市区不一直')
|
||||
this.xsq = newDist;
|
||||
this.getDistList(newDist, x);
|
||||
} else {
|
||||
console.log('新市区跟旧市区一直');
|
||||
this.confirmDist = this.defaultDist[x]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
<div class="row">
|
||||
<div class="row_label"><span>*</span>收货人</div>
|
||||
<div class="row_con">
|
||||
<u--input placeholder="请输入姓名" clearable border="none" v-model="value" @change="change"></u--input>
|
||||
<u--input placeholder="请输入姓名" clearable border="none" v-model="name"></u--input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="row_label"><span>*</span>手机号</div>
|
||||
<div class="row_con">
|
||||
<u--input placeholder="请输入手机号" clearable border="none" v-model="value" @change="change"></u--input>
|
||||
<u--input type="number" placeholder="请输入手机号" clearable border="none" v-model="phone" ></u--input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -24,24 +24,23 @@
|
||||
<div class="row_label">地址</div>
|
||||
<div class="row_con">
|
||||
<div class="choseAddress" @click="chooseAddress">
|
||||
请选择地址
|
||||
<text v-if="showOrientation">请选择地址</text>
|
||||
<text v-if="!showOrientation" style="color: #000;">{{ orientation.region }} {{orientation.district}}</text>
|
||||
</div>
|
||||
|
||||
<div class="currentAddress">
|
||||
<div class="currentAddress" v-if="showOrientation">
|
||||
<div class="currentAddress1">
|
||||
<div class="currentAddress1_left">当前定位:和平里社区综合 服务站</div>
|
||||
<div class="currentAddress1_right">使用</div>
|
||||
<div class="currentAddress1_left">当前定位:{{orientation.district}}</div>
|
||||
<div class="currentAddress1_right" @click="headerConfirmClick">使用</div>
|
||||
</div>
|
||||
<div class="currentAddress2">河北衡水市桃城区</div>
|
||||
<div class="currentAddress2">{{orientation.region}}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row_label">门牌号</div>
|
||||
<div class="row_con noneborder">
|
||||
<u--input placeholder="例:6栋201室" clearable border="none" v-model="value"
|
||||
@change="change"></u--input>
|
||||
<u--input placeholder="例:6栋201室" clearable border="none" v-model="houseNumber"></u--input>
|
||||
<!-- <div class="tips">记得完善门牌号</div> -->
|
||||
</div>
|
||||
</div>
|
||||
@ -69,24 +68,24 @@
|
||||
<div class="row">
|
||||
<div class="row_label"><span>*</span>详细地址</div>
|
||||
<div class="row_con">
|
||||
<u--input placeholder="小区、门牌号" clearable border="none" v-model="value" @change="change"></u--input>
|
||||
<u--input placeholder="小区、门牌号" clearable border="none" v-model="houseNumber"></u--input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="line"></div>
|
||||
<div class="isdef">
|
||||
<div class="isdef" @click="headerSettingDefaultAddressClick">
|
||||
<div class="isdef_left">
|
||||
<div class="isdef_left1">设置默认地址</div>
|
||||
<div class="isdef_left2">提醒:下单时会优先选择</div>
|
||||
</div>
|
||||
<div class="isdef_right">
|
||||
<img src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png" alt="" />
|
||||
<!-- <img src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png" alt="" /> -->
|
||||
<img v-if="isDefault == 2" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png" alt="" />
|
||||
<img v-if="isDefault == 1" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn">确定</div>
|
||||
<div class="btn" @click="headerSubmitClick">确定</div>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
@ -95,6 +94,7 @@
|
||||
import {
|
||||
apiArr
|
||||
} from '../../../api/area';
|
||||
import { apiArr as apiArr2 } from '../../../api/shop';
|
||||
import {
|
||||
picUrl,
|
||||
menuButtonInfo,
|
||||
@ -122,6 +122,16 @@ export default {
|
||||
sf: true,
|
||||
xsq: {},
|
||||
value2: '',
|
||||
|
||||
isShow: false,
|
||||
id: '',
|
||||
type: '',
|
||||
orientation: uni.getStorageSync('location'),
|
||||
name: '',
|
||||
phone: '',
|
||||
houseNumber: '',
|
||||
isDefault: 2,
|
||||
showOrientation: true,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -130,6 +140,7 @@ export default {
|
||||
},
|
||||
chooseAddress() {
|
||||
console.log(123);
|
||||
this.isShow = true;
|
||||
NavgateTo("/pages/shopcity/shopcity")
|
||||
},
|
||||
/////////////////////////////////// 省市区方法///////////////////////////////////////////
|
||||
@ -143,8 +154,9 @@ export default {
|
||||
},
|
||||
|
||||
// 获取市区信息
|
||||
async getCityList(sq, x) {
|
||||
async getCityList(sq, x,) {
|
||||
console.log('11swq', sq);
|
||||
console.log('获取x', x);
|
||||
if (!this.sf) {
|
||||
console.log('省份没变,查市跟区', this.cityList)
|
||||
let newDist = this.cityList[sq];
|
||||
@ -153,6 +165,9 @@ export default {
|
||||
console.log('新市区跟旧市区不一直')
|
||||
this.xsq = newDist;
|
||||
this.getDistList(newDist, x);
|
||||
} else {
|
||||
console.log('新市区跟旧市区一直');
|
||||
this.confirmDist = this.defaultDist[x]
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -166,11 +181,101 @@ export default {
|
||||
},
|
||||
// 获取 县/区 信息
|
||||
async getDistList(xsq, x) {
|
||||
console.log('页面传递的x',x);
|
||||
const res = await request(apiArr.getArea, 'POST', { parent_ad_code: xsq ? xsq.ad_code : this.confirmCity.ad_code }, { silent: false });
|
||||
this.distList = res.rows;
|
||||
this.defaultDist = res.rows;
|
||||
this.confirmDist = res.rows[0] // 区的第一条信息
|
||||
},
|
||||
|
||||
async headerSubmitClick() {
|
||||
console.log('省' ,this.confirmProv1);
|
||||
console.log('xsq' ,this.xsq);
|
||||
console.log('confirmCity' ,this.confirmCity);
|
||||
console.log('confirmDist' ,this.confirmDist);
|
||||
const { confirmProv1, xsq, confirmCity, confirmDist } = this;
|
||||
if(!this.name) {
|
||||
uni.showToast({
|
||||
title: '请输入收货人名称',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(!this.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入收货人手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(this.tab == 0 && this.showOrientation) {
|
||||
uni.showToast({
|
||||
title: '请输入收货地址',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(!this.houseNumber) {
|
||||
uni.showToast({
|
||||
title: '请输入门牌号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(this.type === 'edit') {
|
||||
const res = await request(apiArr2.updateAddress, "POST", {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
phone: this.phone,
|
||||
address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`,
|
||||
house_number: this.houseNumber,
|
||||
is_default: this.isDefault
|
||||
}, { nested: true})
|
||||
console.log('编辑成功', res);
|
||||
if(res.code === 1) {
|
||||
uni.showToast({
|
||||
title: '地址更新成功',
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
} else {
|
||||
const res = await request(apiArr2.addAddress, 'POST', {
|
||||
name: this.name,
|
||||
phone: this.phone,
|
||||
address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`,
|
||||
house_number: this.houseNumber,
|
||||
is_default: this.isDefault
|
||||
}, { nested: true})
|
||||
if(res.code === 1) {
|
||||
uni.showToast({
|
||||
title: '地址添加成功',
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
headerConfirmClick() {
|
||||
this.showOrientation = false;
|
||||
this.isShow = true;
|
||||
this.orientation = uni.getStorageSync('location');
|
||||
},
|
||||
headerSettingDefaultAddressClick() {
|
||||
this.isDefault = this.isDefault == 2 ? 1 : 2;
|
||||
},
|
||||
async init() {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
@ -205,11 +310,35 @@ export default {
|
||||
/////////////////////////////////// 省市区方法///////////////////////////////////////////
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log('12231', options);
|
||||
if(options.item) {
|
||||
const item = JSON.parse(options.item);
|
||||
console.log('1231', item);
|
||||
this.name = item.name;
|
||||
this.phone = item.phone;
|
||||
this.orientation = {
|
||||
region: item.address,
|
||||
district: ''
|
||||
}
|
||||
this.showOrientation = false;
|
||||
this.id = item.id;
|
||||
this.type = 'edit';
|
||||
this.isShow = false;
|
||||
this.isDefault = item.is_default;
|
||||
this.houseNumber = item.house_number;
|
||||
}
|
||||
const meun = menuButtonInfo();
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.init()
|
||||
},
|
||||
onShow() {
|
||||
if(!this.isShow ) return;
|
||||
if(this.orientation.district !== uni.getStorageSync('location').district) {
|
||||
this.orientation = uni.getStorageSync('location');
|
||||
this.showOrientation = false;
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
@ -3,29 +3,27 @@
|
||||
|
||||
<div class="hasAddress">
|
||||
<div class="addressList">
|
||||
<div class="addressItem" v-for="item, index in 3" :key="index" :class="{ 'addressItem_def': index == 0 }">
|
||||
<div class="addressItem" v-for="item, index in list" :key="index" :class="{ 'addressItem_def': index == 0 }">
|
||||
<div class="addressItem_top">
|
||||
高世霞 15901518415 <div class="is_def">默认</div>
|
||||
</div>
|
||||
<div class="addressItem_mid">
|
||||
河北 衡水 桃城区 上海公馆 赞寓17层
|
||||
{{item.name}} {{item.phone}} <div v-if="item.is_default === 1" class="is_def">默认</div>
|
||||
</div>
|
||||
<div class="addressItem_mid">{{item.address}}{{ item.house_number }}</div>
|
||||
<div class="addressItem_footer">
|
||||
<div class="addressItem_footer_left">
|
||||
<div>
|
||||
<div v-if="item.is_default !== 1" @click="headerSettingDefault(item.id)">
|
||||
<image src="http://192.168.0.172:5500/7.15/shop_checked1.png"></image>
|
||||
设为默认
|
||||
</div>
|
||||
|
||||
<div v-if="false">
|
||||
<div v-if="item.is_default === 1">
|
||||
<image src="http://192.168.0.172:5500/7.15/shop_checked2.png"></image>
|
||||
已默认
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="addressItem_footer_right">
|
||||
<div class="btn1" @click="deleteItem">删除</div>
|
||||
<div class="btn2">修改</div>
|
||||
<div class="btn1" @click="deleteItem(item.id )">删除</div>
|
||||
<div class="btn2" @click="editItem(item)">修改</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -46,11 +44,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { apiArr } from '../../../api/shop';
|
||||
import {
|
||||
apiArr
|
||||
} from '../../../api/doorToDoor';
|
||||
import {
|
||||
picUrl,
|
||||
menuButtonInfo,
|
||||
request,
|
||||
NavgateTo
|
||||
@ -62,32 +57,66 @@ export default {
|
||||
localHeight: "",
|
||||
value: 3,
|
||||
type: "error",
|
||||
|
||||
list: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addAddress(){
|
||||
NavgateTo("../addAddress/index")
|
||||
},
|
||||
deleteItem(){
|
||||
|
||||
editItem(item) {
|
||||
NavgateTo(`../addAddress/index?item=${JSON.stringify(item)}`)
|
||||
},
|
||||
|
||||
async headerSettingDefault(id) {
|
||||
const res = await request(apiArr.settingDefaultAddress, 'POST', { id }, { silent: true, nested: true });
|
||||
if(res.code === 1){
|
||||
uni.showToast({
|
||||
title: '设置成功',
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
|
||||
deleteItem(id){
|
||||
const _this = this;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除地址',
|
||||
success: function (res) {
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
const res = await request(apiArr.addressDel, 'POST', { id });
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
_this.init();
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async init() {
|
||||
const res = await request(apiArr.addressList, 'POST', {});
|
||||
this.list = res.address_list;
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
const meun = menuButtonInfo();
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
},
|
||||
onShow() {
|
||||
this.init();
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
@ -267,6 +267,7 @@ export default {
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
this.info = res
|
||||
// 分割图片
|
||||
res.commodity_goods_info_list.forEach(item => {
|
||||
item.goods_detail_pic = item.goods_detail_pic.split(',')
|
||||
item.goods_carousel = item.goods_carousel.split(',')
|
||||
@ -290,14 +291,8 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// changeGG2(item, index) {
|
||||
|
||||
// request(apiArr.addCar,"POST",{
|
||||
// goods_id:item.id,
|
||||
// count:1
|
||||
// })
|
||||
// },
|
||||
|
||||
// 切换规格
|
||||
changeGG(item, index) {
|
||||
this.currentGG = item
|
||||
this.currentGGIndex = index
|
||||
@ -319,7 +314,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
//离开页面的时候 判断添加了多少 删除了多少商品
|
||||
//离开页面的时候直接更新购物车数量(目前接口是 传入商品id 数量。如果有当前商品就更新数量。如果没有就增加商品)
|
||||
getShopCarList() {
|
||||
request(apiArr.getCar, 'POST', {}).then(res => {
|
||||
this.carOrderList = res.commodity_cart_list
|
||||
@ -327,67 +322,41 @@ export default {
|
||||
},
|
||||
|
||||
addCar() {
|
||||
|
||||
let that = this
|
||||
//如果没有当前商品 直接添加一个
|
||||
let goods_id_and_count = []
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { count: 1 }
|
||||
this.info.commodity_goods_info_list.forEach(item => {
|
||||
console.log(item);
|
||||
|
||||
goods_id_and_count.push({
|
||||
goods_id: item.id,
|
||||
count: item.cart_count.count
|
||||
count: 1
|
||||
})
|
||||
})
|
||||
|
||||
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
|
||||
request(apiArr.updateCar, "POST", {
|
||||
goods_id_and_count
|
||||
}).then(res => {
|
||||
that.getShopCar()
|
||||
that.getShopCarList()
|
||||
})
|
||||
// let flag = false
|
||||
// this.carOrderList.forEach(item => {
|
||||
// if (item.goods_id == this.info.commodity_goods_info_list[this.currentGGIndex].id) {
|
||||
// flag = true
|
||||
// }
|
||||
// })
|
||||
// console.log(flag);
|
||||
|
||||
// if (flag) {
|
||||
|
||||
// this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { count: 1 }
|
||||
// let carNum = 0
|
||||
// this.info.commodity_goods_info_list.forEach(item => {
|
||||
// carNum += item.cart_count.count
|
||||
// })
|
||||
// this.carNum = carNum
|
||||
// } else {
|
||||
|
||||
// }
|
||||
|
||||
},
|
||||
|
||||
// 购物车更改
|
||||
changeCar(newValue) {
|
||||
// 修改当前商品在购物车中的数量
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = newValue.value
|
||||
|
||||
// 修改购物车列表中的数量
|
||||
this.carOrderList.forEach(item=>{
|
||||
if(item.commodity_goods_info.id == this.info.commodity_goods_info_list[this.currentGGIndex].id){
|
||||
console.log(item,'item');
|
||||
item.count = newValue.value
|
||||
}
|
||||
})
|
||||
// 计算购物车数量
|
||||
let carNum = 0
|
||||
this.carOrderList.forEach(item=>{
|
||||
carNum += item.count
|
||||
})
|
||||
// let carNum = 0
|
||||
// this.info.commodity_goods_info_list.forEach(item => {
|
||||
// if (item.cart_count) {
|
||||
// carNum += item.cart_count.count
|
||||
// }
|
||||
// })
|
||||
this.carNum = carNum
|
||||
},
|
||||
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
<div class="address_Info" @click="choseAddress" v-if="defAddress">
|
||||
<div class="address_Info_left">
|
||||
<div class="address_Info_left_tit">收货地址</div>
|
||||
<div class="address_Info_left_name">李佳 15901518415</div>
|
||||
<div class="address_Info_left_addr">北京北京市朝阳区珠江绿洲文化广场</div>
|
||||
<div class="address_Info_left_name">{{ defAddress.name }} {{ defAddress.phone }}</div>
|
||||
<div class="address_Info_left_addr">{{ defAddress.address }}{{ defAddress.house_number }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="address_Info" @click="choseAddress" v-if="!defAddress">
|
||||
<div class="address_Info" @click="addAddress" v-if="!defAddress">
|
||||
<div class="address_Info_left noneDef">
|
||||
<div class="address_Info_btn">添加收货地址</div>
|
||||
</div>
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
|
||||
<div class="footer">
|
||||
<div class="btn">立即支付¥{{ totalMony }}</div>
|
||||
<div class="btn" @click="craeteOrder">立即支付¥{{ totalMony }}</div>
|
||||
</div>
|
||||
|
||||
</view>
|
||||
@ -88,14 +88,18 @@ export default {
|
||||
type: "error",
|
||||
carList: [],
|
||||
totalMony: 0,
|
||||
defAddress:{},
|
||||
defAddress: {},
|
||||
|
||||
order_id: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
choseAddress() {
|
||||
NavgateTo('../address/index')
|
||||
},
|
||||
|
||||
addAddress() {
|
||||
NavgateTo('../addAddress/index')
|
||||
},
|
||||
calcTotal() {
|
||||
let total = 0
|
||||
this.carList.forEach(item => {
|
||||
@ -128,6 +132,91 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
craeteOrder() {
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
|
||||
let goods_list = []
|
||||
this.carList.forEach(item => {
|
||||
goods_list.push({
|
||||
goods_id: item.commodity_goods_info.id,
|
||||
count: item.count,
|
||||
})
|
||||
})
|
||||
|
||||
request(apiArr.createOrder, "POST", {
|
||||
goods_list,
|
||||
address_id: this.defAddress.id
|
||||
}).then(res => {
|
||||
uni.hideLoading()
|
||||
this.order_id = res.order_id
|
||||
this.payOrder()
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
payOrder() {
|
||||
request(apiArr.payOrder, "POST", {
|
||||
order_id: this.order_id
|
||||
}).then(res => {
|
||||
let that = this; // 保存组件实例的 this 引用
|
||||
let resCopy = JSON.parse(JSON.stringify(res))
|
||||
this.WxPay(resCopy)
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
WxPay(resCopy) {
|
||||
let that = this
|
||||
uni.requestPayment({
|
||||
"provider": "wxpay",
|
||||
"orderInfo": {
|
||||
"appid": "wxb4018c78fa143450", //
|
||||
"noncestr": resCopy.nonceStr, // 随机字符串
|
||||
"package": resCopy.package, // 固定值
|
||||
"prepayid":resCopy.prepayId,
|
||||
"timestamp": resCopy.timeStamp, // 时间戳(单位:秒)
|
||||
"paysign": resCopy.paySign,
|
||||
"partnerid":resCopy.partnerId
|
||||
},
|
||||
timeStamp: resCopy.timeStamp,
|
||||
nonceStr: resCopy.nonceStr,
|
||||
package: resCopy.package,
|
||||
signType: resCopy.signType,
|
||||
paySign: resCopy.paySign,
|
||||
success(res) {
|
||||
console.log(res);
|
||||
},
|
||||
fail(e) {
|
||||
console.log(e.errMsg);
|
||||
}
|
||||
})
|
||||
// uni.requestPayment({
|
||||
// provider: 'wxpay',
|
||||
// timeStamp: resCopy.timeStamp,
|
||||
// nonceStr: resCopy.nonceStr,
|
||||
// package: resCopy.package,
|
||||
// signType: resCopy.signType,
|
||||
// paySign: resCopy.paySign,
|
||||
// success: function (res) {
|
||||
// console.log('success:' + JSON.stringify(res));
|
||||
// that.queryOrder()
|
||||
// },
|
||||
// fail: function (err) {
|
||||
// console.log('fail:' + JSON.stringify(err));
|
||||
// }
|
||||
// })
|
||||
},
|
||||
queryOrder() {
|
||||
request(apiArr.queryOrder, "POST", {
|
||||
order_id: this.order_id
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.getUserAddress()
|
||||
|
||||
@ -189,6 +189,7 @@ export default {
|
||||
district: res.address.match(/市(.*)/)[1],
|
||||
lat: res.latitude,
|
||||
lng: res.longitude,
|
||||
region: res.address.match(/^(.*?省.*?(?:市|自治州|盟).*?(?:县|区|旗))/)[1], // 省市区
|
||||
};
|
||||
uni.setStorageSync("location", selectLocation); // 缓存数据信息
|
||||
// uni.setStorageSync('city', selectLocation.cityName); // 缓存数据信息
|
||||
|
||||
92
pages/test.vue
Normal file
92
pages/test.vue
Normal file
@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<div class="animation-container" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave">
|
||||
<img :src="spriteImage" :style="spriteStyle" alt="Animation sprite" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SpriteAnimation',
|
||||
data() {
|
||||
return {
|
||||
frame: 1, // 当前帧数 (1-60)
|
||||
type: '外', // 动画类型 ('内'或'外')
|
||||
running: false, // 是否正在执行动画
|
||||
timer: null, // 动画定时器
|
||||
spriteImage: 'http://192.168.0.172:5500/test1.png' // 示例base64图片
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
spriteStyle() {
|
||||
return {
|
||||
position: 'absolute',
|
||||
top: `-${(this.frame - 1) * 120}px`,
|
||||
left: '0px',
|
||||
width: '100%',
|
||||
height: 'auto'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clearAnimationTimer() {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
},
|
||||
startAnimation() {
|
||||
this.clearAnimationTimer()
|
||||
this.running = true
|
||||
|
||||
const targetFrame = this.type === '内' ? 60 : 1
|
||||
const step = this.type === '内' ? 1 : -1
|
||||
const frameDuration = 2000 / 60 // 2秒完成60帧动画
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
this.frame += step
|
||||
|
||||
if ((step > 0 && this.frame >= targetFrame) ||
|
||||
(step < 0 && this.frame <= targetFrame)) {
|
||||
this.frame = targetFrame
|
||||
this.clearAnimationTimer()
|
||||
this.running = false
|
||||
this.checkAutoReverse()
|
||||
}
|
||||
}, frameDuration)
|
||||
},
|
||||
handleMouseEnter() {
|
||||
this.type = '内'
|
||||
if (!this.running) this.startAnimation()
|
||||
},
|
||||
handleMouseLeave() {
|
||||
this.type = '外'
|
||||
if (!this.running) this.startAnimation()
|
||||
},
|
||||
checkAutoReverse() {
|
||||
if (this.type === '外' && this.frame === 60) {
|
||||
this.type = '内'
|
||||
this.startAnimation()
|
||||
} else if (this.type === '内' && this.frame === 1) {
|
||||
this.type = '外'
|
||||
this.startAnimation()
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.clearAnimationTimer()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.animation-container {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
position: relative;
|
||||
border: 1px solid pink;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
left: 20%;
|
||||
top: 200px;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user