Browse Source

修复 详情 添加购物车

master
Mr-Wong-Git 6 days ago
parent
commit
b22831f2eb
  1. 16
      common/config.js
  2. 14
      pages/good/goodsDetail.vue
  3. 23
      utils/requester.js

16
common/config.js

@ -6,12 +6,12 @@
* loginTimeoutPage = "/pages/login/index", // 登录超时或失效的情况下,跳转到的登录页面
*/
module.exports = {
// baseUrl: 'http://uv32vz.natappfree.cc', // 本地
// baseUrl: 'http://192.168.0.105:8116/mall', // 本地
// baseUrl: 'https://39.104.100.138/lpkapi', // 测试服务器
// baseUrl: 'https://lpk.yyundong.com/mallapi', // 测试服务器
baseUrl: 'https://ordermall.yxtsoft.com/lpkapi/mall', // 正式服务器
// tokenName: "Authorization", // 请求头中token的名字,与服务器端对应
loginTimeoutCode: "5001", // 登录超时或失效的情况下,服务器端返回的错误码
loginTimeoutPage: "/pages/login/index", // 登录超时或失效的情况下,跳转到的登录页面
// baseUrl: 'http://uv32vz.natappfree.cc', // 本地
// baseUrl: 'http://192.168.0.200:8100/mall', // 本地
// baseUrl: 'https://39.104.100.138/lpkapi', // 测试服务器
// baseUrl: 'https://lpk.yyundong.com/mallapi', // 测试服务器
baseUrl: 'https://ordermall.yxtsoft.com/lpkapi/mall', // 正式服务器
// tokenName: "Authorization", // 请求头中token的名字,与服务器端对应
loginTimeoutCode: "5001", // 登录超时或失效的情况下,服务器端返回的错误码
loginTimeoutPage: "/pages/login/index", // 登录超时或失效的情况下,跳转到的登录页面
}

14
pages/good/goodsDetail.vue

@ -69,12 +69,12 @@
</view>
</view> -->
<!-- <view
style="display: flex;flex-direction: row; justify-content: center;align-items: center;margin-top: 10px;padding: 0px 10px;margin-bottom: 20px;">
<text style="background: #FF9900; color: #fff;font-size: 14px; padding: 0px 15px;height: 50px;line-height:50px;flex: 1;text-align: center;
border: 1px #FF9900 solid; border-radius: 25px;" @click="showDialog()">加入购物车</text> -->
<view
style="display: flex;flex-direction: row; justify-content: center;align-items: center;margin-top: 10px;padding: 0px 10px;margin-bottom: 20px;">
<text style="background: #FF9900; color: #fff;font-size: 14px; padding: 0px 15px;height: 50px;line-height:50px;flex: 1;text-align: center;
border: 1px #FF9900 solid; border-radius: 25px;" @click="showDialog()">加入购物车</text>
</view>
<!-- <view style="border: 1px #FF9900 solid;border-top-right-radius: 25px; border-bottom-right-radius: 25px;padding: 0px 5px;height: 50px;line-height:50px;flex: 1;
display: flex;flex-direction: row;align-items: center;box-sizing: border-box;justify-content: center;"
@click="gotoCart()">
@ -116,7 +116,7 @@
style="color: #EE752F;border: 1px #EE752F solid;
border-radius: 8px;padding: 1px 10px;font-size: 10px;">{{data.weight}}{{data.specificationUnit}}/{{data.unitName}}</text>
<text style="margin-left: 10px;color: #EE752F;border: 1px #EE752F solid;
<text v-if="data.remarks" style="margin-left: 10px;color: #EE752F;border: 1px #EE752F solid;
border-radius: 8px;padding: 1px 10px;font-size: 10px;">{{data.remarks}}</text>
</view>
@ -390,7 +390,7 @@
goodsNumber: this.data.goodsNumber,
affiliation: this.data.brandId,
price: this.data.mefenPrice,
weight: this.data.weight,
weight: this.data.goodsNumber,
customerSid: getApp().globalData.sid
}

23
utils/requester.js

@ -20,7 +20,7 @@ import token from '@/utils/auth.token.js'
* showFailMessage: true, // 返回失败信息是否显示
* catchError: true, // 是否集中管理返回的success为false的情况,如果为false,在请求处判断code值做业务处理
*/
const request = (options, noLoading,noFailMessage) => {
const request = (options, noLoading, noFailMessage) => {
let _opts = {
url: '', // url String 是 开发者服务器接口地址
data: {}, // data Object/String/ArrayBuffer 否 请求的参数 App 3.3.7 以下不支持 ArrayBuffer 类型
@ -58,6 +58,8 @@ const request = (options, noLoading,noFailMessage) => {
mask: true
})
}
console.log('http-url', _opts.url);
console.log('http-param', _opts.data);
return uni.request({
url: (_baseUrl || '') + (_opts.url || ''),
method: _opts.method,
@ -65,6 +67,7 @@ const request = (options, noLoading,noFailMessage) => {
header: _opts.header,
timeout: _opts.timeout || 60000,
success: res => {
console.log('http-result', res);
if (200 === res.statusCode) {
let data = res.data
if (_opts.catchError) {
@ -161,7 +164,7 @@ const request = (options, noLoading,noFailMessage) => {
complete() {
if (_opts.showLoading) {
console.log("showLoading>>>>>", _opts.showLoading);
uni.hideLoading()
uni.hideLoading()
}
}
@ -170,7 +173,7 @@ const request = (options, noLoading,noFailMessage) => {
}
const req = function(url, method = "GET", data = {}, header = {}, options = {}, noLoading,noFailMessage) {
const req = function(url, method = "GET", data = {}, header = {}, options = {}, noLoading, noFailMessage) {
let _opts = {
url: url,
method: method,
@ -178,21 +181,21 @@ const req = function(url, method = "GET", data = {}, header = {}, options = {},
header: header
}
Object.assign(options, _opts)
return request(options, noLoading,noFailMessage)
return request(options, noLoading, noFailMessage)
}
const get = function(url, data = {}, header = {}, options = {}, noLoading,noFailMessage) {
return req(url, "GET", data, header, options, noLoading,noFailMessage)
const get = function(url, data = {}, header = {}, options = {}, noLoading, noFailMessage) {
return req(url, "GET", data, header, options, noLoading, noFailMessage)
}
const post = function(url, data = {}, header = {}, options = {}, noLoading,noFailMessage) {
return req(url, "POST", data, header, options, noLoading,noFailMessage)
const post = function(url, data = {}, header = {}, options = {}, noLoading, noFailMessage) {
return req(url, "POST", data, header, options, noLoading, noFailMessage)
}
const formpost = function(url, data = {}, header = {}, options = {}, noLoading,noFailMessage) {
const formpost = function(url, data = {}, header = {}, options = {}, noLoading, noFailMessage) {
let _head = {
"content-type": "application/x-www-form-urlencoded"
}
Object.assign(header, _head)
return req(url, "POST", data, header, options, noLoading,noFailMessage)
return req(url, "POST", data, header, options, noLoading, noFailMessage)
}
request.get = get
request.post = post

Loading…
Cancel
Save