From c621ff0ff4022f147d98be2fa33e3cf129ac64e1 Mon Sep 17 00:00:00 2001 From: wangzimeng <3297159934@qq.com> Date: Mon, 28 Jul 2025 17:38:58 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=88=86=E4=BA=AB=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=BA=8C=E7=BB=B4=E7=A0=81=EF=BC=9A=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=94=99=E8=B7=AF=E5=BE=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=202=E3=80=81=E5=8F=91=E5=B8=83=E7=9A=84=E9=9D=99=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=203=E3=80=81=E5=88=86=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=8F=96=E6=B6=88?= =?UTF-8?q?=204=E3=80=81=E7=A7=AF=E5=88=86=E7=9A=84=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=A1=B5=E9=9D=A2=205=E3=80=81=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E5=95=86=E5=9F=8E=EF=BC=9A=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/app/score-shop.vue | 265 ++++-- pages/app/sign.vue | 31 +- pages/index/category.vue | 3 +- pages/index/fabu.vue | 1270 +++++++++++++++++++++++++- sheep/api/app.js | 280 +++--- sheep/components/s-uploader/utils.js | 168 ++-- 6 files changed, 1721 insertions(+), 296 deletions(-) diff --git a/pages/app/score-shop.vue b/pages/app/score-shop.vue index 5a55389..dd5866d 100644 --- a/pages/app/score-shop.vue +++ b/pages/app/score-shop.vue @@ -6,72 +6,79 @@ 当前积分 - 6963 + {{score}} 积分明细 - + - + - + - + - - + + + - 优惠券满100减50 + {{item.name}} - 100积分兑换 + {{item.score}}积分兑换 - - - - - - 优惠券满100减50 - - 100积分兑换 - - - - - - - - 优惠券满100减50 - - 100积分兑换 - - - - + - - + + + + + + {{ item.name }} + + {{item.score}}积分兑换 + + + + + + + + + + + v-if="couponList.length == 0" style="margin-top: 300rpx;"> 暂无数据信息 - --> + + + + + + 是否兑换 + {{couponName}} + + + 取消 + 确定 + + + + - + @@ -87,32 +94,88 @@ reactive } from 'vue'; import _ from 'lodash'; - - const tabMaps = [ - { - name: '优惠券', - value: '0', - }, - { - name: '次数券', - value: '1', - }, + + const listQuery = ref({ + page: 1, + limit: 10, + list_rows: 10, + status: 1, + }) + const tabMaps = [{ + name: '优惠券', + value: '1', + }, + { + name: '次数券', + value: '2', + }, ]; const currentTab = ref(0) + const score = ref(0) //切换tabs function onChange(e) { - console.log('onChange',e); - currentTab.value = e.index - console.log('切换tabs',currentTab.value); - // getLogList(); + console.log('onChange', e); + currentTab.value = e.index + console.log('切换tabs', currentTab.value); + listQuery.value.status = e.value + getCouponList(); } - + //页面跳转 const toPage = (e) => { uni.navigateTo({ url: e }) - + + } + + //满减券 + const couponList = ref([]) + const couponCount = ref(0) + async function getCouponList() { + const res = await sheep.$api.app.scoreShop.fullList({ + page: listQuery.value.page, + limit: listQuery.value.limit, + status: listQuery.value.status, + order: 'normal' + }); + if (res.code === 1) { + couponList.value = res.data.list; + couponCount.value = res.data.count; + score.value = res.data.score + } else { + uni.showToast({ + title: res.msg, + icon: 'none' + }) + } + } + + const showCouponPro = ref(false) + const couponName = ref('') + const couponSelectId = ref('') + function openCouponPro(item) { + showCouponPro.value = true; + couponName.value = item.name; + couponSelectId.value = item.id + } + async function handleCouponSure() { + const res = await sheep.$api.app.scoreShop.exCoupon({ + id: couponSelectId.value + }); + if (res.code === 1) { + uni.showToast({ + title: res.msg, + icon: 'success' + }) + showCouponPro.value = false; + } else { + uni.showToast({ + title: res.msg, + icon: 'error' + }) + showCouponPro.value = false; + } } // 上拉加载更多 @@ -120,7 +183,7 @@ // loadmore(); }); onLoad(() => { - // getData(); + getCouponList(); }); @@ -128,42 +191,43 @@ .fs30 { font-size: 30rpx; } - + .fs60 { font-size: 60rpx; } - + .fs28 { font-size: 28rpx; } - + .bold { font-weight: bold; } - + .c3 { color: #333333; } - + .c9 { color: #999999; } - + .container { background-color: #ffffff; - + height: 100vh; + .conTop { width: 100%; height: 300rpx; background-image: url('https://jiangxiaoxian.0rui.cn/scoreTopBack.png'); background-size: 100%; - + .textLine { position: relative; top: 68rpx; left: 60rpx; display: block; - + .scoreDetail { margin-top: 20rpx; display: flex; @@ -172,34 +236,37 @@ } } } - + .exChangeBox { background-color: #ffffff; width: 690rpx; - + margin-top: 30rpx; + .couponsList { width: 100%; padding: 0 30rpx; display: grid; - grid-template-columns: repeat(2, 1fr);; + grid-template-columns: repeat(2, 1fr); + ; grid-gap: 20px; // display: flex; // justify-content: center; // align-items: center; - - + + .list-item { width: 330rpx; border-radius: 18rpx; box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1); - + .item-text { padding: 30rpx; - + .exchangeBtn { background-color: #fcc74e; height: 70rpx; width: 270rpx; + margin-top: 30rpx; border-radius: 223rpx; align-items: center; justify-content: center; @@ -210,10 +277,56 @@ } } } - + } } + .popupContacted { + width: 660rpx; + height: 477rpx; + background-color: #fff; + display: grid; + border-radius: 18rpx; + + .contactedBox { + width: 660rpx; + height: 325rpx; + padding: 30rpx 0; + // margin-top: 40rpx; + display: grid; + justify-content: center; + align-items: center; + } + + .contactBtn { + width: 660rpx; + height: 92rpx; + border-top: 1rpx solid #eeeeee; + display: flex; + border-radius: 0 0 18rpx 18rpx; + // margin-top: 40rpx; + + .tactBtnBox { + width: 330rpx; + height: 92rpx; + border-right: 1rpx solid #eeeeee; + display: flex; + align-items: center; + justify-content: center; + } + + .tactBtnBox2 { + width: 330rpx; + height: 92rpx; + // border-right: 1rpx solid #eeeeee; + display: flex; + align-items: center; + justify-content: center; + } + } + + } + } \ No newline at end of file diff --git a/pages/app/sign.vue b/pages/app/sign.vue index ae87dd9..66be885 100644 --- a/pages/app/sign.vue +++ b/pages/app/sign.vue @@ -84,7 +84,7 @@ - + 去发布 @@ -125,7 +125,7 @@ - + 去消费 @@ -143,7 +143,7 @@ - + 去分享 @@ -218,6 +218,7 @@ computed, reactive } from 'vue'; + import { showShareModal } from '@/sheep/hooks/useModal'; const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/app/sign.png'); @@ -381,6 +382,30 @@ url: e }) } + + //跳转tabbars + const toTabb = (e) => { + uni.switchTab({ + url: e + }) + } + + //分享功能 + function showShare() { + // 确保使用有效的图片URL + const shareInfo = { + title: '每日签到领积分', + desc: '快来签到领取积分奖励吧', + image: 'https://jiangxiaoxian.0rui.cn/valid-image.png', // 替换为有效的图片URL + params: { + page: 'sign' + } + }; + + // 调用分享方法 + showShareModal(shareInfo); + } + \ No newline at end of file diff --git a/sheep/api/app.js b/sheep/api/app.js index dab454e..833250d 100644 --- a/sheep/api/app.js +++ b/sheep/api/app.js @@ -1,137 +1,151 @@ import request from '@/sheep/request'; -import { baseUrl } from '@/sheep/config'; +import { + baseUrl +} from '@/sheep/config'; export default { - // 系统初始化 - init: (templateId) => - request({ - url: 'index/init', - params: { - templateId, - }, - custom: { - showError: false, - showLoading: false, - }, - }), - // 同步客户端页面到后端 - pageSync: (pages) => - request({ - url: 'index/pageSync', - method: 'POST', - data: { - pages, - }, - custom: { - showError: false, - showLoading: false, - }, - }), - // 发送短信 - sendSms: (data) => - request({ - url: 'index/send', - method: 'POST', - data, - custom: { - showSuccess: true, - loadingMsg: '发送中', - }, - }), - //意见反馈 - feedback: (data) => - request({ - url: 'index/feedback', - method: 'POST', - data, - }), - // 自定义页面 - page: (id) => - request({ - url: 'index/page', - method: 'GET', - params: { - id: id, - }, - }), - //积分商城 - scoreShop: { - list: (params) => - request({ - url: 'app.score_shop', - method: 'GET', - params, - }), - ids: (params = {}) => - request({ - url: 'app.score_shop/ids', - method: 'GET', - params, - }), - detail: (id) => - request({ - url: 'app.score_shop/detail', - method: 'GET', - params: { - id: id, - }, - }), - }, - //小程序直播 - mplive: { - getMpLink: () => - request({ - url: 'app.mplive/getMpLink', - method: 'GET', - }), - getRoomList: (ids) => - request({ - url: 'app.mplive/getRoomList', - method: 'GET', - params: { - ids: ids.join(','), - } - }), - }, + // 系统初始化 + init: (templateId) => + request({ + url: 'index/init', + params: { + templateId, + }, + custom: { + showError: false, + showLoading: false, + }, + }), + // 同步客户端页面到后端 + pageSync: (pages) => + request({ + url: 'index/pageSync', + method: 'POST', + data: { + pages, + }, + custom: { + showError: false, + showLoading: false, + }, + }), + // 发送短信 + sendSms: (data) => + request({ + url: 'index/send', + method: 'POST', + data, + custom: { + showSuccess: true, + loadingMsg: '发送中', + }, + }), + //意见反馈 + feedback: (data) => + request({ + url: 'index/feedback', + method: 'POST', + data, + }), + // 自定义页面 + page: (id) => + request({ + url: 'index/page', + method: 'GET', + params: { + id: id, + }, + }), + //积分商城 + scoreShop: { + fullList: (params) => + request({ + url: 'meal.score/product_list', + method: 'GET', + params, + }), + exCoupon: (data) => + request({ + url: 'meal.score/exchange', + method: 'POST', + data, + }), + list: (params) => + request({ + url: 'app.score_shop', + method: 'GET', + params, + }), + ids: (params = {}) => + request({ + url: 'app.score_shop/ids', + method: 'GET', + params, + }), + detail: (id) => + request({ + url: 'app.score_shop/detail', + method: 'GET', + params: { + id: id, + }, + }), + }, + //小程序直播 + mplive: { + getMpLink: () => + request({ + url: 'app.mplive/getMpLink', + method: 'GET', + }), + getRoomList: (ids) => + request({ + url: 'app.mplive/getRoomList', + method: 'GET', + params: { + ids: ids.join(','), + } + }), + }, - //上传 - upload: (file, group = 'ugc', callback) => { - const token = uni.getStorageSync('token'); - uni.showLoading({ - title: '上传中', - }); - return new Promise((resolve, reject) => { - uni.uploadFile({ - url: baseUrl + '/api/common/upload', - filePath: file, - name: 'file', - formData: { - group, - }, - header: { - Accept: 'text/json', - // Authorization: token, - token: token - }, - success: (uploadFileRes) => { - let result = JSON.parse(uploadFileRes.data); - if (result.code === 0) { - uni.showToast({ - icon: 'none', - title: result.msg, - }); - } else { - return resolve(result.data); - } - }, - fail: (error) => { - console.log('上传失败:', error); - return resolve(false); - }, - complete: () => { - uni.hideLoading(); - }, - }); - }); - }, -}; + //上传 + upload: (file, group = 'ugc', callback) => { + const token = uni.getStorageSync('token'); + uni.showLoading({ + title: '上传中', + }); + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: baseUrl + '/api/common/upload', + filePath: file, + name: 'file', + formData: { + group, + }, + header: { + Accept: 'text/json', + // Authorization: token, + token: token + }, + success: (uploadFileRes) => { + let result = JSON.parse(uploadFileRes.data); + if (result.code === 0) { + uni.showToast({ + icon: 'none', + title: result.msg, + }); + } else { + return resolve(result.data); + } + }, + fail: (error) => { + console.log('上传失败:', error); + return resolve(false); + }, + complete: () => { + uni.hideLoading(); + }, + }); + }); + }, +}; \ No newline at end of file diff --git a/sheep/components/s-uploader/utils.js b/sheep/components/s-uploader/utils.js index c1e8073..49f67f0 100644 --- a/sheep/components/s-uploader/utils.js +++ b/sheep/components/s-uploader/utils.js @@ -3,12 +3,12 @@ * @param {String} name */ export const get_file_ext = (name) => { - const last_len = name.lastIndexOf('.'); - const len = name.length; - return { - name: name.substring(0, last_len), - ext: name.substring(last_len + 1, len), - }; + const last_len = name.lastIndexOf('.'); + const len = name.length; + return { + name: name.substring(0, last_len), + ext: name.substring(last_len + 1, len), + }; }; /** @@ -16,49 +16,49 @@ export const get_file_ext = (name) => { * @param {Array} fileExtname */ export const get_extname = (fileExtname) => { - if (!Array.isArray(fileExtname)) { - let extname = fileExtname.replace(/(\[|\])/g, ''); - return extname.split(','); - } else { - return fileExtname; - } - return []; + if (!Array.isArray(fileExtname)) { + let extname = fileExtname.replace(/(\[|\])/g, ''); + return extname.split(','); + } else { + return fileExtname; + } + return []; }; /** * 获取文件和检测是否可选 */ export const get_files_and_is_max = (res, _extname) => { - let filePaths = []; - let files = []; - if (!_extname || _extname.length === 0) { - return { - filePaths, - files, - }; - } - res.tempFiles.forEach((v) => { - let fileFullName = get_file_ext(v.name); - const extname = fileFullName.ext.toLowerCase(); - if (_extname.indexOf(extname) !== -1) { - files.push(v); - filePaths.push(v.path); - } - }); - if (files.length !== res.tempFiles.length) { - uni.showToast({ - title: `当前选择了${res.tempFiles.length}个文件 ,${ + let filePaths = []; + let files = []; + if (!_extname || _extname.length === 0) { + return { + filePaths, + files, + }; + } + res.tempFiles.forEach((v) => { + let fileFullName = get_file_ext(v.name); + const extname = fileFullName.ext.toLowerCase(); + if (_extname.indexOf(extname) !== -1) { + files.push(v); + filePaths.push(v.path); + } + }); + if (files.length !== res.tempFiles.length) { + uni.showToast({ + title: `当前选择了${res.tempFiles.length}个文件 ,${ res.tempFiles.length - files.length } 个文件格式不正确`, - icon: 'none', - duration: 5000, - }); - } + icon: 'none', + duration: 5000, + }); + } - return { - filePaths, - files, - }; + return { + filePaths, + files, + }; }; /** @@ -66,45 +66,59 @@ export const get_files_and_is_max = (res, _extname) => { * @param {Object} filepath */ export const get_file_info = (filepath) => { - return new Promise((resolve, reject) => { - uni.getImageInfo({ - src: filepath, - success(res) { - resolve(res); - }, - fail(err) { - reject(err); - }, - }); - }); + return new Promise((resolve, reject) => { + if (!filepath) { + reject(new Error('Invalid file path')); + return; + } + + uni.getImageInfo({ + src: filepath, + success(res) { + resolve(res); + }, + fail(err) { + console.error('Failed to get image info:', err); + reject(err); + }, + }); + }); }; /** * 获取封装数据 */ export const get_file_data = async (files, type = 'image') => { - // 最终需要上传数据库的数据 - let fileFullName = get_file_ext(files.name); - const extname = fileFullName.ext.toLowerCase(); - let filedata = { - name: files.name, - uuid: files.uuid, - extname: extname || '', - cloudPath: files.cloudPath, - fileType: files.fileType, - url: files.path || files.path, - size: files.size, //单位是字节 - image: {}, - path: files.path, - video: {}, - }; - if (type === 'image') { - const imageinfo = await get_file_info(files.path); - delete filedata.video; - filedata.image.width = imageinfo.width; - filedata.image.height = imageinfo.height; - filedata.image.location = imageinfo.path; - } else { - delete filedata.image; - } - return filedata; -}; + // 最终需要上传数据库的数据 + let fileFullName = get_file_ext(files.name); + const extname = fileFullName.ext.toLowerCase(); + let filedata = { + name: files.name, + uuid: files.uuid, + extname: extname || '', + cloudPath: files.cloudPath, + fileType: files.fileType, + url: files.path || files.path, + size: files.size, //单位是字节 + image: {}, + path: files.path, + video: {}, + }; + + try { + if (type === 'image') { + const imageinfo = await get_file_info(files.path); + delete filedata.video; + filedata.image.width = imageinfo.width; + filedata.image.height = imageinfo.height; + filedata.image.location = imageinfo.path; + } else { + delete filedata.image; + } + } catch (error) { + console.error('Error processing file data:', error); + // 返回基本文件数据,即使图片信息获取失败 + delete filedata.image; + delete filedata.video; + } + return filedata; +}; \ No newline at end of file