|
|
|
@ -495,6 +495,7 @@ |
|
|
|
|
import * as address from '@/api/address.js' |
|
|
|
|
import * as CartApi from '@/api/cart' |
|
|
|
|
import store from '@/store' |
|
|
|
|
import QQMapWX from '@/utils/qqmap-wx-jssdk' |
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
SkuPopup, |
|
|
|
@ -577,8 +578,8 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad(options) { |
|
|
|
|
console.log(options) |
|
|
|
|
const that = this; |
|
|
|
|
that.getAuthorize(); |
|
|
|
|
that.options = options; |
|
|
|
|
let result = uni.getStorageSync("addressResult") |
|
|
|
|
this.addressResult = result ? result.address_component : this.addressResult |
|
|
|
@ -632,6 +633,69 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 用户授权 |
|
|
|
|
getAuthorize() { |
|
|
|
|
const _this = this |
|
|
|
|
uni.authorize({ |
|
|
|
|
scope: 'scope.userLocation', // 获取地理信息必填的参数,其它参数见文档 |
|
|
|
|
success(res) { |
|
|
|
|
_this.getAdressLocation() |
|
|
|
|
}, |
|
|
|
|
// 授权失败 |
|
|
|
|
fail(err) { |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '温馨提示', |
|
|
|
|
content: '无法获取当前位置,请手动开启授权', |
|
|
|
|
success: function(res) { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
console.log('用户点击确定') |
|
|
|
|
uni.openSetting({ |
|
|
|
|
success(res) { |
|
|
|
|
if (res.authSetting['scope.userLocation']) { |
|
|
|
|
console.log('打开授权设置定位') |
|
|
|
|
_this.getAdressLocation() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} else if (res.cancel) { |
|
|
|
|
console.log('用户点击取消') |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getAdressLocation() { |
|
|
|
|
var that = this; |
|
|
|
|
const tMap = new QQMapWX({ |
|
|
|
|
key: "ZDBBZ-QQX66-YVYSB-M56JB-FGSS5-EIBI4", //开发者密钥 |
|
|
|
|
}); |
|
|
|
|
uni.getLocation({ |
|
|
|
|
type: "gcj02", |
|
|
|
|
geocode: true, |
|
|
|
|
success: (res) => { |
|
|
|
|
that.longitude = res.longitude; |
|
|
|
|
that.latitude = res.latitude; |
|
|
|
|
tMap.reverseGeocoder({ |
|
|
|
|
location: { |
|
|
|
|
latitude: that.latitude, |
|
|
|
|
longitude: that.longitude, |
|
|
|
|
}, |
|
|
|
|
success: function(res) { |
|
|
|
|
uni.setStorageSync("addressResult", res.result); |
|
|
|
|
console.log("当前地址:", res.result); |
|
|
|
|
}, |
|
|
|
|
fail: function(res) { |
|
|
|
|
console.log("定位失败", res); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
fail: () => { |
|
|
|
|
console.log("获取经纬度失败"); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 在线客服 |
|
|
|
|
handleContact() { |
|
|
|
|
// 商城客服设置 |
|
|
|
@ -828,39 +892,39 @@ |
|
|
|
|
}, |
|
|
|
|
//跳转京东小程序详情 |
|
|
|
|
toJDdetal() { |
|
|
|
|
if (this.goods.jd_short_url) { |
|
|
|
|
wx.navigateToMiniProgram({ |
|
|
|
|
appId: 'wx91d27dbf599dff74', //app.json内容 |
|
|
|
|
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(this.goods.jd_short_url), |
|
|
|
|
extraData: { |
|
|
|
|
foo: 'bar' |
|
|
|
|
}, |
|
|
|
|
envVersion: 'release', |
|
|
|
|
success(res) { |
|
|
|
|
// 打开成功 |
|
|
|
|
console.log(res); |
|
|
|
|
console.log("打开成功") |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// #ifndef MP-WEIXIN |
|
|
|
|
window.location.href = this.goods.link; |
|
|
|
|
// #endif |
|
|
|
|
} else { |
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
wx.navigateToMiniProgram({ |
|
|
|
|
appId: 'wx91d27dbf599dff74', |
|
|
|
|
path: '/pages/item/detail/detail?sku=' + this.goods_sku_no, |
|
|
|
|
envVersion: 'release', |
|
|
|
|
success(res) { |
|
|
|
|
// 打开成功 |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// #endif |
|
|
|
|
// #ifndef MP-WEIXIN |
|
|
|
|
window.location.href = this.goods.link; |
|
|
|
|
// #endif |
|
|
|
|
} |
|
|
|
|
if (this.goods.jd_short_url) { |
|
|
|
|
wx.navigateToMiniProgram({ |
|
|
|
|
appId: 'wx91d27dbf599dff74', //app.json内容 |
|
|
|
|
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(this.goods.jd_short_url), |
|
|
|
|
extraData: { |
|
|
|
|
foo: 'bar' |
|
|
|
|
}, |
|
|
|
|
envVersion: 'release', |
|
|
|
|
success(res) { |
|
|
|
|
// 打开成功 |
|
|
|
|
console.log(res); |
|
|
|
|
console.log("打开成功") |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// #ifndef MP-WEIXIN |
|
|
|
|
window.location.href = this.goods.link; |
|
|
|
|
// #endif |
|
|
|
|
} else { |
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
wx.navigateToMiniProgram({ |
|
|
|
|
appId: 'wx91d27dbf599dff74', |
|
|
|
|
path: '/pages/item/detail/detail?sku=' + this.goods_sku_no, |
|
|
|
|
envVersion: 'release', |
|
|
|
|
success(res) { |
|
|
|
|
// 打开成功 |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// #endif |
|
|
|
|
// #ifndef MP-WEIXIN |
|
|
|
|
window.location.href = this.goods.link; |
|
|
|
|
// #endif |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//修改价格 |
|
|
|
|
openPirce(type) { |
|
|
|
@ -1113,7 +1177,8 @@ |
|
|
|
|
that.goods_sku_no = "" |
|
|
|
|
if (info.skuList && info.skuList.length > 0) { |
|
|
|
|
if (info.goods_id) { |
|
|
|
|
that.goods_sku_no = info.skuList.filter(item => item.goods_id === info.goods_id)[0].goods_sku_no; |
|
|
|
|
that.goods_sku_no = info.skuList.filter(item => item.goods_id === info |
|
|
|
|
.goods_id)[0].goods_sku_no; |
|
|
|
|
} |
|
|
|
|
// that.goods_sku_no = info.skuList[0].goods_sku_no |
|
|
|
|
} |
|
|
|
|