This commit is contained in:
zpc 2025-05-04 16:55:07 +08:00
parent 5cb1218193
commit 21f87c8ed2
16 changed files with 1210 additions and 349 deletions

468
App.vue
View File

@ -1,255 +1,259 @@
<script>
import Vue from "vue";
//
import Vue from "vue";
//
export default {
data() {
return {
isFirstLaunch: true, //
}
},
onLaunch: function() {
console.log("App Launch");
// #ifdef MP-WEIXIN
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
//
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: "更新提示",
content: "新版本已经准备好,是否重启应用?",
success(res) {
if (res.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function(res) {
//
});
//#endif
var that = this;
this.$config.init().then(async (data) => {
//
let src = await that.$config.getAppSettingAsync("win_audio");
if (src == null || src == "") {
src = that.$img("/static/mp3/open.mp3");
}
//
const openBgm = uni.createInnerAudioContext();
Vue.prototype.bgmCtx = {};
Vue.prototype.bgmCtx.openBgm = openBgm;
openBgm.src = src;
//
let src2 = await that.$config.getAppSettingAsync("win_audio2");
if (src2 == null || src2 == "") {
src2 = that.$img("/static/mp3/slot_open.mp3");
}
//
const slotBgm = uni.createInnerAudioContext();
// Vue.prototype.bgmCtx = {};
Vue.prototype.bgmCtx.slotBgm = slotBgm;
slotBgm.src = src2;
});
//
this.callLoginRecordApi();
/* 重置首页公告弹窗状态 */
uni.setStorageSync("_is_this_show", false);
/* 清除缓存中的广告id */
uni.removeStorageSync("_ad_id");
/* 清除缓存中的click_id */
uni.removeStorageSync("_click_id");
},
onShow: function() {
console.log("App Show");
// // onLaunch
// if (!this.isFirstLaunch) {
// this.callLoginRecordApi();
// } else {
// this.isFirstLaunch = false; //
// }
},
onHide: function() {
console.log("App Hide");
},
methods: {
//
callLoginRecordApi() {
//
const token = uni.getStorageSync('token');
if (!token) {
console.log('用户未登录,不调用登录记录接口');
return;
}
this.req({
url: 'login_record',
method: 'POST',
success: (res) => {
console.log('登录记录接口调用成功', res);
},
fail: (err) => {
console.log('登录记录接口调用失败', err);
}
});
}
export default {
data() {
return {
isFirstLaunch: true, //
}
};
},
onLaunch: function (options) {
// console.log("App Launch", options, window.location.href);
// #ifdef MP-WEIXIN
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
//
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "新版本已经准备好,是否重启应用?",
success(res) {
if (res.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function (res) {
//
});
//#endif
var that = this;
this.$config.init().then(async (data) => {
//
let src = await that.$config.getAppSettingAsync("win_audio");
if (src == null || src == "") {
src = that.$img("/static/mp3/open.mp3");
}
//
const openBgm = uni.createInnerAudioContext();
Vue.prototype.bgmCtx = {};
Vue.prototype.bgmCtx.openBgm = openBgm;
openBgm.src = src;
//
let src2 = await that.$config.getAppSettingAsync("win_audio2");
if (src2 == null || src2 == "") {
src2 = that.$img("/static/mp3/slot_open.mp3");
}
//
const slotBgm = uni.createInnerAudioContext();
// Vue.prototype.bgmCtx = {};
Vue.prototype.bgmCtx.slotBgm = slotBgm;
slotBgm.src = src2;
});
//
this.callLoginRecordApi();
/* 重置首页公告弹窗状态 */
uni.setStorageSync("_is_this_show", false);
/* 清除缓存中的广告id */
uni.removeStorageSync("_ad_id");
/* 清除缓存中的click_id */
uni.removeStorageSync("_click_id");
//
this.$platform.AppLaunch(options);
},
onShow: function () {
console.log("App Show");
// // onLaunch
// if (!this.isFirstLaunch) {
// this.callLoginRecordApi();
// } else {
// this.isFirstLaunch = false; //
// }
},
onHide: function () {
console.log("App Hide");
},
methods: {
//
callLoginRecordApi() {
//
const token = uni.getStorageSync('token');
if (!token) {
console.log('用户未登录,不调用登录记录接口');
return;
}
this.req({
url: 'login_record',
method: 'POST',
success: (res) => {
console.log('登录记录接口调用成功', res);
},
fail: (err) => {
console.log('登录记录接口调用失败', err);
}
});
}
}
};
</script>
<style lang="scss">
/*每个页面公共css */
@import "./common/animate.css";
@import url("./common/common.css");
@import url("/components/gaoyia-parse/parse.css");
/*每个页面公共css */
@import "./common/animate.css";
@import url("./common/common.css");
@import url("/components/gaoyia-parse/parse.css");
/* 引入字体 */
@font-face {
font-family: "YouSheBiaoTiHei";
src: url($imgurl + "font/YouSheBiaoTiHei.ttf") format("truetype");
}
/* 引入字体 */
@font-face {
font-family: "YouSheBiaoTiHei";
src: url($imgurl + "font/YouSheBiaoTiHei.ttf") format("truetype");
}
@font-face {
font-family: "zihun152hao-jijiachaojihei";
src: url($imgurl + "font/zihun152hao-jijiachaojihei.TTF") format("truetype");
}
@font-face {
font-family: "zihun152hao-jijiachaojihei";
src: url($imgurl + "font/zihun152hao-jijiachaojihei.TTF") format("truetype");
}
@font-face {
font-family: "zihun147hao-xingyuanhei";
src: url($imgurl + "font/zihun147hao-xingyuanhei.TTF") format("truetype");
}
@font-face {
font-family: "zihun147hao-xingyuanhei";
src: url($imgurl + "font/zihun147hao-xingyuanhei.TTF") format("truetype");
}
page {
overflow-x: hidden;
page {
overflow-x: hidden;
&:before {
content: "";
position: fixed;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #1c1b20;
}
}
.ziti {
font-family: YouSheBiaoTiHei;
}
.flex_center {
display: flex;
align-items: center;
}
.hang2 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
}
.hang1 {
overflow: hidden;
/*超出部分隐藏*/
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.icon {
display: flex;
justify-content: center;
align-items: center;
image {
width: 100%;
height: 100%;
}
}
.common_bg {
background-repeat: no-repeat;
background-position: 0 0;
background-size: 100% 100%;
}
.relative {
position: relative;
}
button.hide {
position: absolute;
width: 100% !important;
height: 100% !important;
left: 0;
&:before {
content: "";
position: fixed;
z-index: -1;
top: 0;
z-index: 1;
opacity: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #1c1b20;
}
}
/* 重写组件样式 */
/deep/.uni-noticebar {
padding: 0 !important;
.ziti {
font-family: YouSheBiaoTiHei;
}
.flex_center {
display: flex;
align-items: center;
}
.hang2 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
}
.hang1 {
overflow: hidden;
/*超出部分隐藏*/
white-space: nowrap;
/*不换行*/
text-overflow: ellipsis;
/*超出部分文字以...显示*/
}
.icon {
display: flex;
justify-content: center;
align-items: center;
image {
width: 100%;
height: 100%;
}
}
.common_bg {
background-repeat: no-repeat;
background-position: 0 0;
background-size: 100% 100%;
}
.relative {
position: relative;
}
button.hide {
position: absolute;
width: 100% !important;
height: 100% !important;
left: 0;
top: 0;
z-index: 1;
opacity: 0;
}
/* 重写组件样式 */
/deep/.uni-noticebar {
padding: 0 !important;
margin: 0 !important;
}
/deep/.mescroll-upwarp {
box-sizing: border-box;
min-height: 55px;
padding: 15px 0;
text-align: center;
clear: both;
}
/deep/.cmd-progress-outer {
line-height: 0;
.cmd-progress-bg {
margin: 0 !important;
}
}
/deep/.mescroll-upwarp {
box-sizing: border-box;
min-height: 55px;
padding: 15px 0;
text-align: center;
clear: both;
.uni-tabbar__bd {
height: 50px !important;
}
.uni-tabbar__icon {
height: 50px !important;
}
@keyframes m-zoom {
0% {
transform: scale(1);
}
/deep/.cmd-progress-outer {
line-height: 0;
.cmd-progress-bg {
margin: 0 !important;
}
50% {
transform: scale(0.9);
}
.uni-tabbar__bd {
height: 50px !important;
}
.uni-tabbar__icon {
height: 50px !important;
}
@keyframes m-zoom {
0% {
transform: scale(1);
}
50% {
transform: scale(0.9);
}
100% {
transform: scale(1);
}
100% {
transform: scale(1);
}
}
</style>

View File

@ -39,11 +39,11 @@ let currentEnv = testing;
// 判断当前环境
// #ifdef H5
if (process.env.NODE_ENV === 'production') {
currentEnv = production;
} else if (process.env.NODE_ENV === 'testing') {
currentEnv = testing;
}
// if (process.env.NODE_ENV === 'production') {
// currentEnv = production;
// } else if (process.env.NODE_ENV === 'testing') {
// currentEnv = testing;
// }
// #endif
// #ifdef MP-WEIXIN

View File

@ -56,5 +56,23 @@ class BasePlatform {
ua: navigator?.userAgent || ''
};
}
downloadFile(url) {
return new Promise((resolve, reject) => {
throw new Error('子类必须实现 downloadFile 方法');
});
}
AppLaunch(options) {
throw new Error('子类必须实现 AppLaunch 方法');
}
/**
* 获取订单号
*/
getOrderNo() {
throw new Error('子类必须实现 getOrderNo 方法');
}
delOrderNo(){
}
}
export default BasePlatform;

View File

@ -1,5 +1,24 @@
import BasePlatform from './BasePlatform';
function parseQueryString(queryString) {
// 如果以 ? 开头,先去掉 ?
if (queryString.startsWith('?')) {
queryString = queryString.substring(1);
}
const params = {};
const pairs = queryString.split('&');
for (const pair of pairs) {
const [key, value] = pair.split('=');
// 解码 URI 组件
params[key] = decodeURIComponent(value);
}
return params;
}
class H5Platform extends BasePlatform {
constructor() {
super();
@ -55,13 +74,14 @@ class H5Platform extends BasePlatform {
url: '/pages/other/choose_address',
events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
acceptDataFromOpenedPage: function (data) {
console.log(data)
selectAddress: function (data) {
console.log(data, { userName: data.address.receiver_name, telNumber: data.address.receiver_phone, detailed_address: data.address.detailed_address })
resolve({ userName: data.address.receiver_name, telNumber: data.address.receiver_phone, detailed_address: data.address.detailed_address });
},
someEvent: function (data) {
console.log(data)
}
},
success: function (res) {
// 通过eventChannel向被打开页面传送数据
@ -70,5 +90,86 @@ class H5Platform extends BasePlatform {
})
});
}
downloadFile(url) {
return new Promise((resolve, reject) => {
try {
// 创建一个隐藏的a标签
const a = document.createElement('a');
a.href = url;
a.download = url.split('/').pop() || 'download'; // 使用URL中的文件名或默认名称
a.style.display = 'none';
document.body.appendChild(a);
a.click(); // 触发下载
document.body.removeChild(a); // 清理DOM
resolve({ success: true });
} catch (error) {
console.error('下载失败:', error);
// 降级方案,直接打开
window.location.href = url;
resolve({ success: false, error: error.message });
}
});
}
AppLaunch(options) {
console.log("AppLaunch", options);
if (options.query) {
let query = options.query;
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query['out_trade_no'] != null) {
//支付宝跳转过来的
//重定向url
let url = window.location.origin + window.location.pathname;
let out_trade_no = query['out_trade_no'];
uni.setStorageSync('pay_order_num', out_trade_no);
// alert('存入订单编号' + out_trade_no)
const delKey = ['charset', 'out_trade_no', 'method', 'total_amount', 'sign', 'trade_no', 'auth_app_id', 'version', 'app_id', 'sign_type', 'seller_id', 'timestamp'];
for (const key of delKey) {
delete query[key];
}
let str = Object.entries(query)
.map(([key, value]) => `${key}=${value}`)
.join('&')
url += "?" + str;
console.log('支付成功,重定向页面。',url);
window.location.href = url;
}
// query['']
// {
// "goods_id": "1081",
// "type_text": "%E6%97%A0%E9%99%90%E8%B5%8F",
// "order_no": "MH_ZFAH5ZFB2025050449989950960",
// "charset": "UTF-8",
// "out_trade_no": "MH_ZFAH5ZFB2025050449989950960",
// "method": "alipay.trade.wap.pay.return",
// "total_amount": "0.01",
// "sign": "JD2PDNDh2qTi/y4wiqtsyJSc5uPy1OgO5W7NaYRdc/ctHT85yVJP9fDVpJAIXRDj/xd8oWpT9a2BSrNfqIbZ0sT0Fa8ha15unfi9RX+jYEkKAa2Grz0rkcv3YOlMni9vThCRdmNPCzh0fKLCKFRBZiuxPIFW7qgoRxFkWvziR8dUi0GccleOSUV6Z3W+HG6b+Ru3fgZSRMm+8+d0UXrH5wi7KIgJja+ZbAnVYkh+4R7BjxS1zpUPMXNzej9fAFHO6UD8RBobYi1r6D3gYpKJaChVUJXaXkRqU/6ybgUbX7FsvviCYoEGUkukiq9HCaKZ/bfrD3TvoAicC4aXo6p7Dw==",
// "trade_no": "2025050422001402751446415564",
// "auth_app_id": "2021005141643914",
// "version": "1.0",
// "app_id": "2021005141643914",
// "sign_type": "RSA2",
// "seller_id": "2088170936712914",
// "timestamp": "2025-05-04 01:41:48"
// }
}
}
getOrderNo() {
return new Promise((resolve, reject) => {
//window.location.search
let query = parseQueryString(window.location.search);
if (query['method'] != null && query['method'] == "alipay.trade.wap.pay.return" && query['out_trade_no'] != null) {
//表示还在支付请求中,还未开始重定向
console.log('window.location.search',window.location.search);
resolve(null);
return;
}
let pay_order_num = uni.getStorageSync('pay_order_num');
// alert("获取订单编号"+pay_order_num)
setTimeout(() => { uni.removeStorageSync('pay_order_num'); }, 2000)
resolve(pay_order_num);
});
}
}
export default H5Platform;

View File

@ -88,5 +88,57 @@ class MiniProgramPlatform extends BasePlatform {
});
});
}
downloadFile(url) {
return new Promise((resolve, reject) => {
// 下载图片到本地
wx.downloadFile({
url: url,
success: (res) => {
if (res.statusCode === 200) {
const tempFilePath = res.tempFilePath; // 获取临时文件路径
// 保存图片到相册
wx.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: () => {
uni.showToast({
title: '保存成功',
icon: 'success',
});
},
fail: (err) => {
uni.showToast({
title: '保存失败',
icon: 'none',
});
console.error('保存失败', err);
},
});
} else {
uni.showToast({
title: '图片下载失败',
icon: 'none',
});
console.error('图片下载失败', res);
}
},
fail: (err) => {
uni.showToast({
title: '图片下载失败',
icon: 'none',
});
console.error('图片下载失败', err);
},
});
});
}
AppLaunch(options) {
console.log("AppLaunch", options);
}
getOrderNo() {
return new Promise((resolve, reject) => {
resolve(null);
});
}
delOrderNo(){}
}
export default MiniProgramPlatform;

View File

@ -16,14 +16,7 @@ class RequestManager {
* @returns {Boolean} 是否在白名单中
*/
static isUrlInWhitelist(url) {
// let iswx = ConfigManager.GetVersion();
// // 根据版本使用不同的白名单
// if (!iswx) {
// // 非微信版本只允许 login_record
// return apiWhiteList.includes('login_record') && url.indexOf('login_record') > -1;
// }
// 检查URL是否包含白名单中的任一项
return apiWhiteList.some(whiteItem => url.indexOf(whiteItem) > -1);
}

View File

@ -0,0 +1,64 @@
import RequestManager from '../request';
/**
* 添加收货地址
* @param {Object} data 地址信息
* @returns {Promise}
*/
export const addAddress = async (data) => {
return await RequestManager.post('/addAddress', data);
};
/**
* 更新收货地址
* @param {Object} data 地址信息
* @returns {Promise}
*/
export const updateAddress = async (data) => {
return await RequestManager.post('/updateAddress', data);
};
/**
* 获取默认收货地址
* @returns {Promise}
*/
export const getDefaultAddress = async () => {
return await RequestManager.get('/getDefaultAddress');
};
/**
* 获取收货地址列表
* @returns {Promise}
*/
export const getAddressList = async () => {
return await RequestManager.get('/getAddressList');
};
/**
* 删除收货地址
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const deleteAddress = async (data) => {
return await RequestManager.post('/deleteAddress', data);
};
/**
* 设置默认收货地址
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const setDefaultAddress = async (data) => {
return await RequestManager.post('/setDefaultAddress', data);
};
/**
* 获取地址详情
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const getAddressDetail = async (id) => {
return await RequestManager.get('/getAddressDetail', { id });
};

View File

@ -45,7 +45,7 @@
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/shouye/huanxiang",
"style": {
@ -196,7 +196,7 @@
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/sangdai/sangdai",
"style": {
@ -252,8 +252,8 @@
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/infinite/index",
"style": {
@ -331,51 +331,50 @@
}
},
{
"path" : "pages/infinite/reward_records",
"style" :
{
"path": "pages/infinite/reward_records",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/shouye/danye",
"style" :
{
"path": "pages/shouye/danye",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/other/prize_draw",
"style" :
{
"path": "pages/other/prize_draw",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/other/order_list",
"style" :
{
"path": "pages/other/order_list",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/other/order_info",
"style" :
{
"path": "pages/other/order_info",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/shouye/slots",
"style" :
{
"path": "pages/shouye/slots",
"style": {
"navigationStyle": "custom"
}
},
{
"path" : "pages/other/choose_address",
"style" :
{
"path": "pages/other/choose_address",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/other/address_edit",
"style": {
"navigationStyle": "custom"
}
}
@ -464,6 +463,7 @@
"borderStyle": "black",
"backgroundColor": "#FFFFFF",
"iconWidth": "24px",
"iconHeight": "24px",
"list": [{
"pagePath": "pages/shouye/index",
"iconPath": "static/tabbar/m1.png",

View File

@ -183,6 +183,11 @@ export default {
this.sendRuleData = res.data
}
});
this.$platform.getOrderNo().then(order_num => {
if (order_num != null && order_num != "") {
that.$c.msg("购买成功!");
}
})
},
onShow() {

View File

@ -0,0 +1,366 @@
<template>
<page-container title="编辑地址" :showBack="true">
<view class="address-form">
<view class="form-item">
<view class="form-label required">收货人</view>
<input class="form-input" type="text" v-model="addressData.receiver_name" placeholder="收货人姓名" />
</view>
<view class="form-item">
<view class="form-label required">电话</view>
<input class="form-input" type="number" v-model="addressData.receiver_phone" placeholder="收货人电话"
maxlength="11" />
</view>
<view class="form-item address-item">
<view class="form-label required address-label">详细地址</view>
<textarea class="form-textarea" v-model="addressData.detailed_address" placeholder="请填写详细地址"
auto-height />
</view>
<view class="form-item switch-item">
<view class="form-label">设为默认</view>
<switch :checked="addressData.is_default === 1" @change="switchChange" color="#1296db" />
</view>
</view>
<view class="btn-save" @click="saveAddress">
<text>保存</text>
</view>
<view class="btn-delete" v-if="isEdit" @click="showDeleteConfirm">
<text>删除</text>
</view>
</page-container>
</template>
<script>
import PageContainer from '@/components/page-container/page-container.vue'
import { addAddress, updateAddress, deleteAddress, getAddressDetail } from '@/common/server/userAddress.js'
export default {
components: {
PageContainer
},
data() {
return {
isEdit: false,
addressId: null,
addressData: {
receiver_name: '',
receiver_phone: '',
detailed_address: '',
is_default: 0
},
eventChannel: null
}
},
onLoad(options) {
this.eventChannel = this.getOpenerEventChannel();
//
if (options && options.id) {
this.isEdit = true;
this.addressId = options.id;
//
this.getAddressDetail();
}
},
methods: {
//
async getAddressDetail() {
try {
uni.showLoading({
title: '加载中...'
});
const res = await getAddressDetail(this.addressId);
uni.hideLoading();
if (res.status === 1 && res.data) {
// API
this.addressData = {
receiver_name: res.data.receiver_name,
receiver_phone: res.data.receiver_phone,
detailed_address: res.data.detailed_address,
is_default: res.data.is_default === 1 ? 1 : 0
};
} else {
uni.showToast({
title: res.msg || '获取地址详情失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('获取地址详情失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
//
switchChange(e) {
this.addressData.is_default = e.detail.value ? 1 : 0;
},
//
async saveAddress() {
//
if (!this.addressData.receiver_name) {
return uni.showToast({
title: '请输入收货人姓名',
icon: 'none'
});
}
if (!this.addressData.receiver_phone) {
return uni.showToast({
title: '请输入联系电话',
icon: 'none'
});
}
//
const phoneReg = /^1[3-9]\d{9}$/;
if (!phoneReg.test(this.addressData.receiver_phone)) {
return uni.showToast({
title: '手机号格式不正确',
icon: 'none'
});
}
if (!this.addressData.detailed_address) {
return uni.showToast({
title: '请输入详细地址',
icon: 'none'
});
}
try {
uni.showLoading({
title: '保存中...'
});
let res;
if (this.isEdit) {
//
res = await updateAddress({
...this.addressData,
id: this.addressId
});
} else {
//
res = await addAddress(this.addressData);
}
uni.hideLoading();
if (res.status === 1) {
uni.showToast({
title: '保存成功',
icon: 'success'
});
//
setTimeout(() => {
//
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
if (prevPage && prevPage.$vm) {
// load
prevPage.$vm.load && prevPage.$vm.load();
}
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '保存失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('保存地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
//
showDeleteConfirm() {
uni.showModal({
title: '提示',
content: '确定要删除该收货地址吗?',
success: async (res) => {
if (res.confirm) {
await this.deleteAddress();
}
}
});
},
//
async deleteAddress() {
try {
uni.showLoading({
title: '删除中...'
});
const res = await deleteAddress({
id: this.addressId
});
uni.hideLoading();
if (res.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
//
setTimeout(() => {
//
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
if (prevPage && prevPage.$vm) {
// load
prevPage.$vm.load && prevPage.$vm.load();
}
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('删除地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
}
}
}
</script>
<style lang="scss">
.address-form {
background-color: #fff;
padding: 0 30rpx;
.form-item {
display: flex;
align-items: center;
min-height: 100rpx;
border-bottom: 1px solid #eee;
.form-label {
width: 180rpx;
font-size: 30rpx;
color: #333;
&.required::before {
content: '*';
color: #ff4d4f;
margin-right: 4rpx;
}
}
.form-input {
flex: 1;
height: 100rpx;
font-size: 30rpx;
}
.form-textarea {
flex: 1;
width: 100%;
min-height: 100rpx;
font-size: 30rpx;
padding: 20rpx 0;
}
.form-value {
flex: 1;
display: flex;
justify-content: space-between;
align-items: center;
height: 100rpx;
font-size: 30rpx;
.placeholder {
color: #999;
}
.arrow {
color: #ccc;
margin-left: 10rpx;
}
}
&.switch-item {
justify-content: space-between;
}
&.address-item {
flex-direction: column;
align-items: flex-start;
.address-label {
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.form-textarea {
width: 100%;
margin-top: 10rpx;
}
}
}
}
.btn-save {
position: fixed;
bottom: 140rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #1296db;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: bold;
border-radius: 45rpx;
}
.btn-delete {
position: fixed;
bottom: 30rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #fff;
color: #666;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
border-radius: 45rpx;
border: 1px solid #ddd;
}
</style>

View File

@ -1,42 +1,304 @@
<template>
<page-container title="选择地址" :showBack="true">
<view class="address-list">
<view v-for="(item, index) in addressList" :key="index" class="address-item">
<view class="address-radio" @click="selectAddress(item)">
<radio :checked="item.id === selectedAddressId" color="#1296db" />
</view>
<view class="address-content" @click="selectAddress(item)">
<view class="address-top">
<text class="name">{{ item.receiver_name }}</text>
<text class="phone">{{ item.receiver_phone }}</text>
<text v-if="item.is_default === 1" class="default-tag">默认</text>
</view>
<view class="address-bottom">
<text class="address-text">{{ item.detailed_address }}</text>
</view>
</view>
<view class="edit-btn" @click="editAddress(item)">
<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
width="24" height="24">
<path
d="M391.467 736.322a31.99 31.99 0 0 1-13.783 8.126l-232.261 66.798c-12.088 3.477-23.276-7.711-19.799-19.799l66.798-232.261a32 32 0 0 1 8.126-13.782l472.869-472.87c12.496-12.496 32.758-12.496 45.254 0L864.335 218.2c12.497 12.496 12.497 32.758 0 45.255L391.467 736.322z m248.009-516.709l77.781 77.782 56.569-56.569-77.782-77.782-56.568 56.569z m-50.912 50.911L265.88 593.209l-31.401 109.182 109.182-31.401 322.685-322.684-77.782-77.782zM129.001 889h768v72h-768v-72z"
fill="#999999" />
</svg>
</view>
<view class="delete-btn" @click="showDeleteConfirm(item)">
<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
width="24" height="24">
<path
d="M417.06 790.286V285.224c0-22.014-17.86-39.874-39.872-39.874-22.014 0-39.874 17.86-39.874 39.874v505.062c0 22.01 17.86 39.87 39.874 39.87 22.012-0.002 39.872-17.862 39.872-39.87z m398.732 93.036c0 29.36-23.804 53.162-53.162 53.162H230.986c-29.36 0-53.164-23.802-53.164-53.162V245.35H98.074v664.552c0 58.72 47.61 106.328 106.33 106.328h584.806c58.72 0 106.33-47.608 106.33-106.328V245.35h-79.748v637.972z m-159.494-93.036V285.224c0-22.014-17.86-39.874-39.872-39.874-22.018 0-39.876 17.86-39.876 39.874v505.062c0 22.01 17.86 39.87 39.876 39.87 22.014-0.002 39.872-17.862 39.872-39.87zM935.412 59.276H576.55c0-29.36-23.8-53.164-53.162-53.164h-53.164c-29.36 0-53.166 23.804-53.166 53.164H84.784c-22.012 0-39.874 17.86-39.874 39.874 0 22.014 17.86 39.874 39.874 39.874h850.628c22.014 0 39.874-17.858 39.874-39.874 0-22.014-17.86-39.874-39.874-39.874z"
fill="#999999" />
</svg>
</view>
</view>
<view v-if="addressList.length === 0" class="empty-tip">
<text>暂无收货地址</text>
</view>
</view>
<view class="add-btn" @click="addNewAddress">
<text>新增地址</text>
</view>
<template #nav-right>
<view @click="confirmSelection">确定</view>
</template>
</page-container>
</template>
<script>
import PageContainer from '@/components/page-container/page-container.vue'
import PageContainer from '@/components/page-container/page-container.vue'
import { getAddressList, deleteAddress } from '@/common/server/userAddress.js'
export default {
components: {
PageContainer
},
data() {
return {
addressList: [],
selectedAddressId: null,
eventChannel: null
}
},
onLoad() {
this.load();
//
this.eventChannel = this.getOpenerEventChannel();
// acceptDataFromOpenerPageeventChannel
this.eventChannel.on('acceptDataFromOpenerPage', (data) => {
console.log('从打开页面接收的数据:', data);
if (data && data.selectedAddressId) {
this.selectedAddressId = data.selectedAddressId;
}
});
},
methods: {
async load() {
try {
const res = await getAddressList();
if (res.status === 1 && res.data) {
//
const defaultAddress = res.data.find(item => item.is_default === 1);
if (defaultAddress && !this.selectedAddressId) {
this.selectedAddressId = defaultAddress.id;
}
export default {
components: {
PageContainer
//
this.addressList = res.data;
} else {
uni.showToast({
title: res.msg || '获取地址列表失败',
icon: 'none'
});
}
} catch (error) {
console.error('获取地址列表失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
data() {
return {}
selectAddress(item) {
//
this.selectedAddressId = item.id;
},
onLoad() {
this.load();
// test.vue
const eventChannel = this.getOpenerEventChannel();
eventChannel.emit('acceptDataFromOpenedPage', {
data: 'data from test page'
editAddress(item) {
uni.navigateTo({
url: '/pages/other/address_edit?id=' + item.id
});
eventChannel.emit('someEvent', {
data: 'data from test page for someEvent'
});
// // acceptDataFromOpenerPageeventChannel
eventChannel.on('acceptDataFromOpenerPage', function(data) {
console.log(data)
})
},
methods: {
async load() {
},
addNewAddress() {
uni.navigateTo({
url: '/pages/other/address_edit'
});
},
//
showDeleteConfirm(item) {
uni.showModal({
title: '提示',
content: '确定要删除该收货地址吗?',
success: async (res) => {
if (res.confirm) {
await this.deleteAddress(item.id);
}
}
});
},
//
async deleteAddress(id) {
try {
uni.showLoading({
title: '删除中...'
});
const res = await deleteAddress({
id: id
});
uni.hideLoading();
if (res.status === 1) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
//
this.load();
} else {
uni.showToast({
title: res.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('删除地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
//
confirmSelection() {
//
if (!this.selectedAddressId) {
return uni.showToast({
title: '请选择一个收货地址',
icon: 'none'
});
}
//
const selectedAddress = this.addressList.find(item => item.id === this.selectedAddressId);
if (!selectedAddress) {
return uni.showToast({
title: '所选地址不存在',
icon: 'none'
});
}
//
if (this.eventChannel) {
this.eventChannel.emit('selectAddress', {
address: selectedAddress
});
//
uni.navigateBack();
}
}
}
}
</script>
<style lang="scss">
.address-list {
padding: 0 30rpx;
background-color: #fff;
.address-item {
display: flex;
align-items: center;
padding: 30rpx 0;
border-bottom: 1px solid #eee;
&:last-child {
border-bottom: none;
}
.address-radio {
width: 60rpx;
display: flex;
justify-content: center;
align-items: center;
}
.address-content {
flex: 1;
margin: 0 20rpx;
.address-top {
margin-bottom: 10rpx;
.name {
font-size: 32rpx;
font-weight: bold;
margin-right: 20rpx;
}
.phone {
font-size: 28rpx;
color: #666;
}
.default-tag {
display: inline-block;
font-size: 22rpx;
color: #fff;
background-color: #1296db;
padding: 4rpx 10rpx;
border-radius: 6rpx;
margin-left: 16rpx;
}
}
.address-bottom {
.address-text {
font-size: 28rpx;
color: #333;
line-height: 1.5;
}
}
}
.edit-btn,
.delete-btn {
width: 60rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 10rpx;
.icon {
font-size: 40rpx;
color: #999;
}
}
}
.empty-tip {
text-align: center;
padding: 60rpx 0;
color: #999;
font-size: 28rpx;
}
}
.add-btn {
position: fixed;
bottom: 30rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #1296db;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: bold;
border-radius: 45rpx;
}
</style>

View File

@ -427,6 +427,11 @@ export default {
this.$nextTick(() => {
this.$refs.mescrollRef.mescroll.optUp.empty.tip = '~ 快来抽赏吧 ~'
})
this.$platform.getOrderNo().then(order_num => {
if (order_num != null && order_num != "") {
this.$c.msg("支付成功~")
}
});
},
computed: {
/* 当前选中可兑换金额 */
@ -544,7 +549,7 @@ export default {
this.canReload = false
this.$platform.chooseAddress().then(res => {
console.log(res);
this.addData = res
this.canReload = true;
});

View File

@ -64,7 +64,7 @@
</view>
<view class="align-center" v-if="pageData.goods">
<view class="align-center"> <text>{{ pageData.goods.num }}</text> /{{ pageData.goods.stock
}}
}}
</view>
<view style="margin-left: 58rpx;">赏品余量</view>
<view class="align-center">
@ -285,7 +285,11 @@ export default {
// this.aniSrc = path
// }
// })
this.$platform.getOrderNo().then(order_num => {
if (order_num != null && order_num != "") {
this.getPrize(order_num);
}
});
this.$c.getRule(10).then((res) => {
if (res.status == 1) {
this.sendRuleData = res.data;
@ -367,7 +371,7 @@ export default {
if (!order_num) {
return;
}
let that = this;
setTimeout(() => {
this.req({
url: "prizeorderlog",
@ -382,7 +386,11 @@ export default {
this.getPrize(order_num);
return;
}
if (that.buyNum == 0 || that.buyNum == null) {
if (res.data.prize_num != null) {
that.buyNum = res.data.prize_num;
}
}
// this.aniShow = true
// setTimeout(() => {
// this.aniShow = false

View File

@ -382,7 +382,13 @@ export default {
this.couponData = data
this.confirmSubmit([0, this.buyNum])
})
this.$platform.getOrderNo().then(order_num => {
console.log("order_num", order_num);
if (order_num != null && order_num != "") {
// alert('' + order_num)
this.getPrize(order_num);
}
});
this.$c.getRule(10).then(res => {
if (res.status == 1) {
@ -519,7 +525,7 @@ export default {
if (!order_num) {
return
}
let that = this;
setTimeout(() => {
this.req({
url: 'infinite_prizeorderlog',
@ -538,8 +544,14 @@ export default {
this.getPrize(order_num)
return
}
// console.log(' res.data.prize_num', res.data.prize_num);
if (that.buyNum == 0 || that.buyNum == null) {
if (res.data.prize_num != null) {
that.buyNum = res.data.prize_num;
}
}
// that.nu
this.bgmCtx.openBgm.play()
this.open('resPop')
// }, 1300)

View File

@ -247,12 +247,12 @@ export default {
}
//
if (!this.codeSent) {
return uni.showToast({
title: '请先发送验证码',
icon: 'none'
});
}
// if (!this.codeSent) {
// return uni.showToast({
// title: '',
// icon: 'none'
// });
// }
//
try {

View File

@ -50,6 +50,7 @@
<!-- // -->
<view class="" style="flex-direction: row; display: flex; width: 686rpx; margin: 40rpx auto;">
<button v-if="!ish5" open-type="share" class="invite-btn">立即邀请</button>
<button v-if="ish5" class="invite-btn" @click="yaoaing()">立即邀请</button>
<button class="invite-btn2" style="margin-left: 20rpx;" @click="showPosterPopup">生成海报</button>
</view>
@ -129,47 +130,17 @@ export default {
console.log(uni.getStorageSync('userinfo').ID)
},
methods: {
yaoaing() {
uni.setClipboardData({
data: window.location.origin + '/pages/shouye/index?pid=' + uni.getStorageSync('userinfo').ID
});
this.$c.msg("链接已复制,快去分享吧~")
},
saveImageToPhotosAlbum() {
const imageUrl = this.logo_image; //
//
wx.downloadFile({
url: imageUrl,
success: (res) => {
if (res.statusCode === 200) {
const tempFilePath = res.tempFilePath; //
//
wx.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: () => {
uni.showToast({
title: '保存成功',
icon: 'success',
});
},
fail: (err) => {
uni.showToast({
title: '保存失败',
icon: 'none',
});
console.error('保存失败', err);
},
});
} else {
uni.showToast({
title: '图片下载失败',
icon: 'none',
});
console.error('图片下载失败', res);
}
},
fail: (err) => {
uni.showToast({
title: '图片下载失败',
icon: 'none',
});
console.error('图片下载失败', err);
},
});
this.$platform.downloadFile(imageUrl).then(res => {
console.log(res)
})
},
getHaiBao() {
return this.$baseUrl + '/api/generate_urllinks?userId=' + uni.getStorageSync('userinfo').ID;