From e36c84a9f14ec8c1944c29dadb589292079d2829 Mon Sep 17 00:00:00 2001 From: jiazhipeng Date: Mon, 12 May 2025 11:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E5=88=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/addressAdd.vue | 398 ++++++++++++++ components/cartData.vue | 455 +++++++++++++++ components/contactAdd.vue | 265 +++++++++ package-lock.json | 11 + package.json | 19 + pages.json | 19 + static/css/base.css | 36 ++ static/js/CommonFunction.js | 30 +- static/js/request.js | 129 ++--- subPackages/techan/detail.vue | 519 +++++++----------- .../techan/{techanList.vue => index.vue} | 458 +++++++--------- subPackages/techan/order.vue | 134 ++--- 12 files changed, 1700 insertions(+), 773 deletions(-) create mode 100644 components/addressAdd.vue create mode 100644 components/cartData.vue create mode 100644 components/contactAdd.vue create mode 100644 package-lock.json create mode 100644 package.json rename subPackages/techan/{techanList.vue => index.vue} (64%) diff --git a/components/addressAdd.vue b/components/addressAdd.vue new file mode 100644 index 0000000..ec68b5b --- /dev/null +++ b/components/addressAdd.vue @@ -0,0 +1,398 @@ + + + + + diff --git a/components/cartData.vue b/components/cartData.vue new file mode 100644 index 0000000..3521934 --- /dev/null +++ b/components/cartData.vue @@ -0,0 +1,455 @@ + + + + + \ No newline at end of file diff --git a/components/contactAdd.vue b/components/contactAdd.vue new file mode 100644 index 0000000..c6d7d8a --- /dev/null +++ b/components/contactAdd.vue @@ -0,0 +1,265 @@ + + + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..922878f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "ydui-district": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/ydui-district/-/ydui-district-1.1.0.tgz", + "integrity": "sha512-MBhvfaR5Gkn6MUmEnrH1A7IFB5igALuDgtIF+gz3dRwNwW9+KOmih7z+xZFfGluMsEbWaT7C3lWOckYsLZQnFg==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..2f2856a --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "cgc_wechat", + "version": "1.0.0", + "description": "", + "main": "main.js", + "dependencies": { + "ydui-district": "^1.1.0" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "http://123.60.98.226:3000/chenkainan/cgc_WeChat.git" + }, + "author": "", + "license": "ISC" +} diff --git a/pages.json b/pages.json index 8129427..8396550 100644 --- a/pages.json +++ b/pages.json @@ -21,6 +21,25 @@ "style": { "navigationBarTitleText": "uni-app" } + }, + { + "path": "techan/index", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "techan/detail", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "techan/order", + "style": { + "navigationBarTitleText": "确认订单" + } } ] }], diff --git a/static/css/base.css b/static/css/base.css index 83ecd6b..2442a04 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -69,3 +69,39 @@ view { color: #999999; } +.flex{ + display: flex; +} +.flex-shrink-0{ + flex-shrink: 0; +} +.flex-1{ + flex: 1; +} +.flex-wrap{ + flex-wrap: wrap; +} +.w-full{ + width: 100%; +} +.w-1rpx{ + width: 1rpx; +} +.h-1rpx{ + height: 1rpx; +} +.relative{ + position: relative; +} +.absolute{ + position: absolute; +} +.flex-items-center{ + align-items: center; +} +.no-scrollbar::-webkit-scrollbar{ + display: none; +} +.font-bold{ + font-weight: bold; +} \ No newline at end of file diff --git a/static/js/CommonFunction.js b/static/js/CommonFunction.js index cde3d8a..b2af6a5 100644 --- a/static/js/CommonFunction.js +++ b/static/js/CommonFunction.js @@ -90,7 +90,7 @@ Vue.prototype.showImg = img => { if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) { return img; } else { - return this.NEWAPIURL + img; + return Vue.prototype.NEWAPIURL + img; } } @@ -222,4 +222,32 @@ Vue.prototype.getHeadImg = type => { ).then(res => { return res.data[0].image }); +} +// 判断是否去外部链接 +Vue.prototype.goOtherDetail = (item,type) => { + if(item.link_type == 1) { + // 外部小程序 + uni.navigateToMiniProgram({ + shortLink: item.ext_link + }) + return true + }else if(item.link_type == 2){ + // 外部H5 + uni.navigateTo({ + url: '/subPackages/webPage/webPage?url=' + item.ext_link + }); + return true + } +} +// 根据类型判断详情页 +Vue.prototype.goDetailByType= function(item){ + let res = this.goOtherDetail(item) + if (res) { + return + } + + uni.navigateTo({ + url: `/subPackages/techan/detail?id=?${item.id}` + }) + } \ No newline at end of file diff --git a/static/js/request.js b/static/js/request.js index 5513e1d..28d247f 100644 --- a/static/js/request.js +++ b/static/js/request.js @@ -1,77 +1,58 @@ -import Vue from 'vue'; -import store from '@/store'; +import Vue from 'vue' +import store from '@/store' -// 定义 API URL -const DEV_API_URL = 'https://api.cloud.sz-trip.com'; -const PROD_API_URL = 'https://api.cloud.sz-trip.com'; -const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL; +let NEWAPIURL = 'https://tlgz.sz-trip.com' +Vue.prototype.NEWAPIURL = NEWAPIURL -// 获取token -const getToken = () => { - const userInfoFromStorage = uni.getStorageSync('userInfo'); - if (userInfoFromStorage) { - const userInfo = JSON.parse(userInfoFromStorage); - if (userInfo.token) { - return userInfo.token; - } - } - return store.state.user.userInfo.token; -}; +Vue.prototype.Post = (params, apiurl) => { + if (uni.getStorageSync('userInfo') && JSON.parse(uni.getStorageSync('userInfo')).token) params.token = JSON.parse(uni.getStorageSync('userInfo')).token + else if (store.state.user.userInfo.token) params.token = store.state.user.userInfo.token + params.token = "aa3940ea-57f5-412e-9803-4035d5115994" + return new Promise((resolve, reject) => { + uni.showLoading({ + title: '加载中' + }) + uni.request({ + method: params.method || 'GET', + url: NEWAPIURL + apiurl, + data: params || {}, + header: params.header || { + 'content-type': 'application/json', + 'token': params.token || '' + }, + success: res => { + uni.hideLoading() + if (res.data.code === 1) { + resolve(res.data) + } else { + setTimeout(() => { + uni.showToast({ + title: res.data.msg, + icon: 'none' + }) + reject(null) + }, 0) + if (res.data.code === 401) { + store.commit('changeLoginPath') + } + } + }, + fail: err => { + console.log('err', err) + uni.hideLoading() + setTimeout(() => { + uni.showToast({ + title: err.msg || err.data.msg, + icon: 'none' + }) + }, 0) + if (err.data.code === 401) { + store.commit('changeLoginPath') + } + reject(err) + } + }) + }) +} -// 定义错误处理函数 -const handleError = (res, reject) => { - setTimeout(() => { - uni.showToast({ - title: res.data?.msg || res.msg, - icon: 'none' - }); - reject(res); - }, 0); - if (res.data?.code === 401) { - store.commit('changeLoginPath'); - } -}; - -// 挂载到 Vue 原型上 -Vue.prototype.NEWAPIURL = NEWAPIURL; -// #ifdef H5 -Vue.prototype.NEWAPIURL = '/api'; -// #endif - -Vue.prototype.Post = (params = {}, apiurl) => { - const token = getToken(); - if (token) { - params.token = token; - } - return new Promise((resolve, reject) => { - uni.showLoading({ - title: '加载中' - }); - uni.request({ - method: params.method || 'GET', - url: Vue.prototype.NEWAPIURL + apiurl, - data: params, - header: { - 'content-type': 'application/json', - 'token': token || '' - }, - success: (res) => { - console.log('success', res.data); - uni.hideLoading() - if (res.data.code === 200 || res.data.code === 1) { - resolve(res.data); - } else { - handleError(res, reject); - } - }, - fail: (err) => { - console.log('err', err); - uni.hideLoading() - handleError(err, reject); - } - }); - }); -}; - -export default NEWAPIURL; - \ No newline at end of file +export default NEWAPIURL diff --git a/subPackages/techan/detail.vue b/subPackages/techan/detail.vue index 8733984..6c47d8a 100644 --- a/subPackages/techan/detail.vue +++ b/subPackages/techan/detail.vue @@ -20,86 +20,77 @@ - + {{ info.list_images.split(',').length }}张 - + {{ info.money / 100 }} - {{ info.title }} {{ item }} + {{ info.title }} - - - - 选择: - - - {{sku[productIndex].title || '暂无可选规格'}} + + + + + + {{item.title}} + {{item.money/100}} - - - 产品简介 + + 购买须知 + + + + 商品须知 - - + - + @@ -140,7 +133,7 @@ 不可购买 - 不可加购 + @@ -158,22 +151,20 @@ - - + + + {{addCartOrOrder?'加入购物车':'立即购买'}} - --> +