Initial Commit

This commit is contained in:
quantulr
2024-05-06 15:34:15 +08:00
commit e3a0666d5a
307 changed files with 28969 additions and 0 deletions

View File

@ -0,0 +1,279 @@
// pages/index/index_address/index_address.js
const qqMap = require('../../../utils/qqmap-wx-jssdk.js')
const qqmapsdk = new qqMap({
key: 'UTFBZ-PQZLW-AX5R6-OWOG6-SRRBH-7FFEL'
});
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
point: [],
addressName: '当前地址',
pay:false,
},
//复制
fz(e){
wx.setClipboardData({
data: e.currentTarget.dataset.fz,
})
},
//选择地址
pointXz: function (e) {
let index = e.currentTarget.dataset.index;
let dataList = this.data.point;
console.log(dataList[index].storesProvince + dataList[index].storesCity + dataList[index].storesArea + dataList[index].storesDetailed)
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]  // 上一页
// 调用上一个页面的setData 方法将数据存储
prevPage.setData({
address: dataList[index].storesProvince + dataList[index].storesCity + dataList[index].storesArea + dataList[index].storesDetailed,
addressId: dataList[index].id,
orderPick: 1,
})
wx.navigateBack();
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.pay){
//支付选择自提点进入
this.setData({
pay:options.pay
})
}
this.map({
type: 1//当前地址 2重新定位
})
},
map(options) {
var that = this;
wx.getSetting({
success(res) {
console.log('get-setting', res.authSetting);
// 只返回用户请求过的授权
let auth = res.authSetting;
if (auth['scope.userLocation']) {
// 已授权,申请定位地址
if (options.type == 1) {
that.toAddress();
} else {
that.again();
}
} else if (auth['scope.userLocation'] === undefined) {
// 用户没有请求过的授权,不需要我们主动弹窗,微信会提供弹窗
if (options.type == 1) {
that.toAddress();
} else {
that.again();
}
} else if (!auth['scope.userLocation']) {
// 没有授权过,需要用户重新授权
// 这个弹窗是为了实现点击不然openSetting会失败
wx.showModal({
title: '是否授权位置信息?',
content: '需要获取您的位置信息,请确认授权',
success: res => {
if (res.confirm) {
wx.openSetting({
success(res) {
console.log('位置信息', res.authSetting);
console.log('open-setting-suc', res.authSetting);
let setting = res.authSetting;
if (!setting['scope.userLocation']) {
wx.showToast({
title: '位置信息授权失败',
icon: 'none',
});
} else {
// 地址授权成功,申请定位地址
if (options.type == 1) {
that.toAddress();
} else {
that.again();
}
}
},
fail(err) {
// 需要点击有时候没有点击是无法触发openSetting
console.log('open-setting-fail', err);
}
});
}
}
});
}
}
});
},
// 调用地址
toAddress: function () {
var that = this
wx.showLoading({
title: '加载中..',
mask: true
})
wx.getLocation({
//定位类型 wgs84, gcj02
// wgs84 返回 gps 坐标gcj02 返回可用于wx.openLocation的坐标
type: 'gcj02',
//获取位置成功
success: function (ress) {
console.log(ress) //获取的的当前位置的详细信息
that.setData({
latitude: ress.latitude,
longitude: ress.longitude
})
//经纬度转化为详细位置
qqmapsdk.reverseGeocoder({
location: {
latitude: ress.latitude,
longitude: ress.longitude
},
success: function (resss) {
wx.hideLoading()
console.log(resss)
var region = [];
that.setData({
addressNo: 1,//地址授权
region: region,
addressName: resss.result.address + resss.result.formatted_addresses.recommend,
})
//获取自提点
that.getStores()
},
fail: function (err) {
wx.hideLoading()
console.log(err)
}
})
},
//获取位置失败
fail: function (err) {
console.log("获取位置信息失败,请返回重试")
wx.showToast({
title: '获取位置信息失败,请返回重试',
icon: 'none'
})
wx.hideLoading()
},
//接口调用结束的回调函数(调用成功、失败都会执行)
complete: function (info) {
console.log("完成")
},
})
},
again: function (e) {
console.log(this.data.latitude)
console.log(this.data.longitude)
let latitude = this.data.latitude;
let longitude = this.data.longitude;
wx.chooseLocation({
latitude: latitude,
longitude: longitude,
success: res => {
// success
console.log(res)
this.setData({
addressName: res.address + res.name,
latitude: res.latitude,
longitude: res.longitude,
})
//获取自提点
this.getStores()
},
fail: function () { },
complete: function () {
// complete
},
})
},
//获取门店列表
getStores() {
wx.showLoading({
title: '加载中',
})
wx.request({
url: app.globalData.ip + '/wisdommining/api/user/getStores',
method: 'GET',
header: {
"content-type": "application/x-www-form-urlencoded",
},
data: {
latitude: this.data.latitude,
longitude: this.data.longitude,
},
success: res => {
console.log(res)
wx.hideLoading()
if (res.data.code == 1) {
let point = res.data.value;
for (let i = 0; i < point.length; i++) {
point[i].location = (point[i].distance / 1000).toFixed(2)
}
this.setData({
point: point
})
} else {
wx.showModal({
title: '获取数据失败!',
content: res.data.message,
showCancel: false,
})
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
})

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "自提点"
}

View File

@ -0,0 +1,42 @@
<!-- <view class="top_fi">
<view class="top">
<view class="search">
<view class="search_address GStitleOne" catchtap="cityName">{{cityName}}</view>
<image class="search_down" src="/icon/c-down.png" catchtap="cityName"></image>
<view class="search_l"></view>
<image class="search_icon" src="/icon/search.png"></image>
<input placeholder="搜索商品" bindinput="search_input" placeholder-style="color:#aaa;"></input>
</view>
</view>
</view> -->
<view class="new">当前地址</view>
<view class="new_address display_J_B display_A_C">
<view class="new_address__l GStitleOne">{{addressName}}</view>
<view class="new_address__r display_A_C" catchtap="again">
<image src="/icon/address.png"></image>重新定位
</view>
</view>
<view class="title">附近提货点</view>
<view wx:if='{{point.length!=0}}' class="address-all" style="margin-bottom:220rpx;min-height:700rpx;">
<view class="address" wx:for='{{point}}' wx:key='index' catchtap="{{pay?'pointXz':''}}" data-index='{{index}}'>
<view class="address-l" style="width:100%;">
<view class="address-cont display_J_B">
<view class="address-cont1 GStitleTwo">{{item.storesProvince + item.storesCity + item.storesArea + item.storesDetailed}}</view>
<view class="address-cont2">
{{item.storesPhone}}
<text catchtap="fz" data-fz='{{item.storesPhone}}' style="padding-left: 10rpx;color: #2fa4f5;">复制</text>
</view>
</view>
<view class="location-name display_J_S display_A_C">
<view class="l-location GStitleOne">{{item.location}}km内</view>
<text></text>
<view class="l-name GStitleOne">{{item.storesName}}</view>
</view>
</view>
</view>
</view>
<view wx:if='{{point.length==0}}' class="address-all display_A_C display_J_C" style="padding:20rpx 0; margin-bottom:220rpx;min-height:700rpx;">
<view class="empty">当前区域暂无自提点,请选择其他区域~</view>
</view>

View File

@ -0,0 +1,176 @@
/* pages/index/index_address/index_address.wxss */
page{
background-color: #f5f5f5;
}
.top {
height: 100rpx;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx;
}
.top_fi {
width: 100%;
background: #fff;
}
.search {
font-size: 24rpx;
flex: 1;
display: flex;
align-items: center;
height: 60rpx;
background-color: #f5f5f5;
border-radius: 40rpx;
padding-left: 39rpx;
}
.search_address{
width: 100rpx;
}
.search_l{
width: 2rpx;
height: 36rpx;
background-color: #d2d2d2;
border-radius: 1rpx;
}
.search_down{
width: 14rpx;
height: 8rpx;
margin: 0 20rpx 0 14rpx;
}
.search_icon{
width: 32rpx;
height: 32rpx;
margin:0 20rpx 0 30rpx;
}
.search input {
width: 400rpx;
}
.sear {
font-size: 24rpx;
color: #999;
padding-left: 30rpx;
}
.new{
padding: 0 30rpx;
height: 75rpx;
line-height: 75rpx;
font-size: 28rpx;
color: #999999;
}
.new_address{
width:690rpx;
padding: 0 30rpx;
height: 100rpx;
background-color: #ffffff;
border-radius: 20rpx;
}
.new_address__l{
font-size: 32rpx;
color: #333333;
width: 450rpx;
}
.new_address__r{
font-size: 24rpx;
color: #2fa4f5;
}
.new_address__r image{
width: 23rpx;
height: 34rpx;
margin-right: 10rpx;
}
.title{
font-size: 28rpx;
color: #999999;
padding: 30rpx 30rpx 0;
line-height: 70rpx;
}
.address-all{
width: 750rpx;
background-color: #ffffff;
border-radius: 20rpx;
}
.address{
width: 690rpx;
padding:20rpx 30rpx;
/* height: 90rpx; */
border-bottom: 1rpx #e5e5e5 solid;
}
.address:last-child{
border-bottom:none;
}
.address-l{
display: flex;
flex-wrap: wrap;
align-content: space-between;
width: 100%;
height: 100%;
}
.address-cont{
font-size: 28rpx;
color: #333333;
width: 100%;
line-height: 40rpx;
}
.address-cont1{
width:400rpx;
}
.address-cont2{
font-size: 28rpx;
color: #999999;
width: 280rpx;
text-align: right;
}
.address-name{
font-size: 32rpx;
color: #999999;
}
.address-name text{
margin-left: 40rpx;
}
.address-r {
height: 100%;
}
.address-r image{
width: 33rpx;
height: 35rpx;
}
.location-name{
font-size:28rpx;
color: #999999;
width: 100%;
line-height: 30rpx;
margin-top: 15rpx;
}
.location-name text{
width: 2rpx;
height: 30rpx;
background-color: #a0a0a0;
margin: 0 20rpx;
}
.l-location{
width: 155rpx;
}
.l-name{
width: 480rpx;
}
.add{
width: 750rpx;
height: 100rpx;
line-height: 100rpx;
background-color: #ffffff;
font-size: 28rpx;
color: #ee7b1e;
text-align: center;
position: fixed;
bottom: 0;
left: 0;
}
.empty{
font-size: 28rpx;
color: #999999;
}