diff --git a/App.vue b/App.vue
index fb63f89..9012496 100644
--- a/App.vue
+++ b/App.vue
@@ -1,255 +1,259 @@
\ No newline at end of file
diff --git a/common/env.js b/common/env.js
index 8937f6c..5c0c3fa 100644
--- a/common/env.js
+++ b/common/env.js
@@ -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
diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js
index 5886c54..fa2001c 100644
--- a/common/platform/BasePlatform.js
+++ b/common/platform/BasePlatform.js
@@ -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;
\ No newline at end of file
diff --git a/common/platform/H5Platform.js b/common/platform/H5Platform.js
index 317ead6..a3b756b 100644
--- a/common/platform/H5Platform.js
+++ b/common/platform/H5Platform.js
@@ -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;
\ No newline at end of file
diff --git a/common/platform/MiniProgramPlatform.js b/common/platform/MiniProgramPlatform.js
index 792fe06..6f632de 100644
--- a/common/platform/MiniProgramPlatform.js
+++ b/common/platform/MiniProgramPlatform.js
@@ -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;
\ No newline at end of file
diff --git a/common/request.js b/common/request.js
index 6567145..6d69d8a 100644
--- a/common/request.js
+++ b/common/request.js
@@ -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);
}
diff --git a/common/server/userAddress.js b/common/server/userAddress.js
new file mode 100644
index 0000000..31cfdb2
--- /dev/null
+++ b/common/server/userAddress.js
@@ -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 });
+};
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 44f093b..fcd66ef 100644
--- a/pages.json
+++ b/pages.json
@@ -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",
diff --git a/pages/mall/index.vue b/pages/mall/index.vue
index a77a9c1..284d8de 100644
--- a/pages/mall/index.vue
+++ b/pages/mall/index.vue
@@ -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() {
diff --git a/pages/other/address_edit.vue b/pages/other/address_edit.vue
new file mode 100644
index 0000000..2293a59
--- /dev/null
+++ b/pages/other/address_edit.vue
@@ -0,0 +1,366 @@
+
+
+
+
+ 收货人
+
+
+
+
+ 电话
+
+
+
+
+ 详细地址
+
+
+
+
+ 设为默认
+
+
+
+
+
+ 保存
+
+
+
+ 删除
+
+
+
+
+
+
+
diff --git a/pages/other/choose_address.vue b/pages/other/choose_address.vue
index 4787438..74481c2 100644
--- a/pages/other/choose_address.vue
+++ b/pages/other/choose_address.vue
@@ -1,42 +1,304 @@
+
+
+
+
+
+
+
+ {{ item.receiver_name }}
+ {{ item.receiver_phone }}
+ 默认
+
+
+ {{ item.detailed_address }}
+
+
+
+
+
+
+
+
+
+
+
+ 暂无收货地址
+
+
+
+
+ 新增地址
+
+
+ 确定
+
\ No newline at end of file
diff --git a/pages/sangdai/sangdai.vue b/pages/sangdai/sangdai.vue
index 16d9a27..39b5968 100644
--- a/pages/sangdai/sangdai.vue
+++ b/pages/sangdai/sangdai.vue
@@ -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;
});
diff --git a/pages/shouye/detail.vue b/pages/shouye/detail.vue
index 029ab57..4945988 100644
--- a/pages/shouye/detail.vue
+++ b/pages/shouye/detail.vue
@@ -64,7 +64,7 @@
第 {{ pageData.goods.num }} /{{ pageData.goods.stock
- }}箱
+ }}箱
赏品余量
@@ -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
diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue
index ac00ab6..8373f34 100644
--- a/pages/shouye/detail_wuxian.vue
+++ b/pages/shouye/detail_wuxian.vue
@@ -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)
diff --git a/pages/user/login.vue b/pages/user/login.vue
index d05da4f..b3802ab 100644
--- a/pages/user/login.vue
+++ b/pages/user/login.vue
@@ -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 {
diff --git a/pages/user/tui-guang.vue b/pages/user/tui-guang.vue
index 140d41e..c6151ce 100644
--- a/pages/user/tui-guang.vue
+++ b/pages/user/tui-guang.vue
@@ -50,6 +50,7 @@
+
@@ -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;