|
@@ -8,8 +8,8 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
|
|
|
- imageList: [],//商店首页
|
|
|
- licenseList: [],//店铺图片
|
|
|
+ imageList: [], //商店首页
|
|
|
+ licenseList: [], //店铺图片
|
|
|
merchant: null,
|
|
|
store: null,
|
|
|
stores: null,
|
|
@@ -27,8 +27,8 @@ Page({
|
|
|
html: null,
|
|
|
content: null,
|
|
|
id: null,
|
|
|
- address:'',
|
|
|
- locations:null,
|
|
|
+ address: '',
|
|
|
+ locations: null,
|
|
|
},
|
|
|
getHtml(e) { //从组件获取值
|
|
|
let html = e.detail.content.html
|
|
@@ -36,7 +36,9 @@ Page({
|
|
|
// this.setData({ html: html })
|
|
|
// let field = event.currentTarget.dataset.field;
|
|
|
// let html = event.detail.content.html;
|
|
|
- this.setData({ html: html })
|
|
|
+ this.setData({
|
|
|
+ html: html
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
insertImage() { //图片上传插入示例
|
|
@@ -87,7 +89,7 @@ Page({
|
|
|
this.setData({
|
|
|
image: e.detail
|
|
|
})
|
|
|
- console.log('图片',this.data.image);
|
|
|
+ console.log('图片', this.data.image);
|
|
|
} else {
|
|
|
this.setData({
|
|
|
image: []
|
|
@@ -118,17 +120,17 @@ Page({
|
|
|
},
|
|
|
async determine() {
|
|
|
let image = []
|
|
|
- if(this.data.image[0].url){
|
|
|
+ if (this.data.image[0].url) {
|
|
|
for (let index = 0; index < this.data.image.length; index++) {
|
|
|
let item = this.data.image[index];
|
|
|
image.push(item.url)
|
|
|
}
|
|
|
// 设置图片格式判断
|
|
|
- console.log('店铺图片',image);
|
|
|
- }else{
|
|
|
- image=this.data.image
|
|
|
+ console.log('店铺图片', image);
|
|
|
+ } else {
|
|
|
+ image = this.data.image
|
|
|
}
|
|
|
- console.log(this.data.name, image, this.data.storeName, this.data.perCapita, this.data.desc, this.data.workingTime, this.data.html,this.data.locations);
|
|
|
+ console.log(this.data.name, image, this.data.storeName, this.data.perCapita, this.data.desc, this.data.workingTime, this.data.html, this.data.locations);
|
|
|
let query = new Parse.Query("ShopStore")
|
|
|
|
|
|
let ShopStore = await query.get(this.data.id)
|
|
@@ -136,19 +138,19 @@ Page({
|
|
|
ShopStore.set("name", this.data.name)
|
|
|
ShopStore.set("cover", this.data.cover)
|
|
|
ShopStore.set("image", image)
|
|
|
- if(this.data.locations){
|
|
|
+ if (this.data.locations) {
|
|
|
ShopStore.set("location", this.data.locations)
|
|
|
- }else{
|
|
|
- wx.showToast({
|
|
|
- title: '请选择民宿地址',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return
|
|
|
+ } else {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '请选择民宿地址',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
}
|
|
|
ShopStore.set("storeName", this.data.storeName)
|
|
|
- if(Number(this.data.perCapita)){
|
|
|
+ if (Number(this.data.perCapita)) {
|
|
|
ShopStore.set("perCapita", Number(this.data.perCapita))
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
wx.showToast({
|
|
|
title: '请输入正确人均消费',
|
|
|
icon: 'none'
|
|
@@ -164,36 +166,36 @@ Page({
|
|
|
title: '修改成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
});
|
|
|
- },1000)
|
|
|
+ }, 1000)
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: async function(options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
|
|
|
|
|
|
|
|
|
let merchant = wx.getStorageSync('merchant'); //用户
|
|
|
let ShopStore = new Parse.Query('ShopStore')
|
|
|
ShopStore.notEqualTo('isDeleted', "true")
|
|
|
- ShopStore.equalTo('company',company)
|
|
|
+ ShopStore.equalTo('company', company)
|
|
|
ShopStore.include('user')
|
|
|
- ShopStore.equalTo('user',merchant.objectId)
|
|
|
+ ShopStore.equalTo('user', merchant.objectId)
|
|
|
let store = await ShopStore.first()
|
|
|
store = store.toJSON()
|
|
|
console.log(store);
|
|
|
let imageList = []
|
|
|
let licenseList = []
|
|
|
- // store.cover[0].forEach(i => {
|
|
|
+ // store.cover[0].forEach(i => {
|
|
|
imageList.push({
|
|
|
- url: store.cover
|
|
|
- })
|
|
|
- // })
|
|
|
+ url: store.cover
|
|
|
+ })
|
|
|
+ // })
|
|
|
console.log(imageList);
|
|
|
store.image.forEach(i => {
|
|
|
licenseList.push({
|
|
@@ -214,9 +216,9 @@ Page({
|
|
|
html: store.content,
|
|
|
id: store.objectId,
|
|
|
licenseList: licenseList,
|
|
|
- locations:store.location
|
|
|
+ locations: store.location
|
|
|
})
|
|
|
- console.log('首页',this.data.locations);
|
|
|
+ console.log('首页', this.data.locations);
|
|
|
this.Getlocation()
|
|
|
this.selectComponent('#hf_editor').setHtml(this.data.html);
|
|
|
this.getQiniuOption()
|
|
@@ -234,54 +236,56 @@ Page({
|
|
|
console.log(this.data.uploadURL, this.data.domain, this.data.uptokenURL);
|
|
|
},
|
|
|
getUptoken() {
|
|
|
- return Parse.Cloud.run('qiniu_uptoken', { company: company })
|
|
|
+ return Parse.Cloud.run('qiniu_uptoken', {
|
|
|
+ company: company
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
- onReady: function() {
|
|
|
+ onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow: function() {
|
|
|
+ onShow: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
- onHide: function() {
|
|
|
+ onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
- onUnload: function() {
|
|
|
+ onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
- onPullDownRefresh: function() {
|
|
|
+ onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
- onReachBottom: function() {
|
|
|
+ onReachBottom: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
- onShareAppMessage: function() {
|
|
|
+ onShareAppMessage: function () {
|
|
|
|
|
|
},
|
|
|
//选择地理位置
|
|
@@ -299,7 +303,7 @@ Page({
|
|
|
let locations = new Parse.GeoPoint(latitude, longitude)
|
|
|
this.setData({
|
|
|
locations,
|
|
|
- address:address
|
|
|
+ address: address
|
|
|
})
|
|
|
console.log(locations);
|
|
|
console.log(address + name);
|
|
@@ -315,38 +319,41 @@ Page({
|
|
|
//解析地理位置
|
|
|
Getlocation() {
|
|
|
// 假设 this.storeList[0].location 是一个 Parse.GeoPoint 对象
|
|
|
- const storeLocation = this.data.locations;
|
|
|
+ if (this.data.locations) {
|
|
|
+ const storeLocation = this.data.locations;
|
|
|
|
|
|
- // 从 GeoPoint 对象中获取经纬度
|
|
|
- const latitude = storeLocation.latitude; // 纬度
|
|
|
- const longitude = storeLocation.longitude; // 经度
|
|
|
+ // 从 GeoPoint 对象中获取经纬度
|
|
|
+ const latitude = storeLocation.latitude; // 纬度
|
|
|
+ const longitude = storeLocation.longitude; // 经度
|
|
|
|
|
|
- console.log('获取到的经纬度:', latitude, longitude); // 添加日志
|
|
|
+ console.log('获取到的经纬度:', latitude, longitude); // 添加日志
|
|
|
+
|
|
|
+ // 调用 API 解析地址
|
|
|
+ wx.request({
|
|
|
+ url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
+ data: {},
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ success: (ops) => { // 使用箭头函数
|
|
|
+ console.log(ops);
|
|
|
+ const address = ops.data.result.formatted_address;
|
|
|
+ this.setData({
|
|
|
+ address: address,
|
|
|
+ });
|
|
|
+ console.log(this.data.address);
|
|
|
+ },
|
|
|
+ fail: function (resq) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '信息提示',
|
|
|
+ content: '请求失败',
|
|
|
+ showCancel: false,
|
|
|
+ confirmColor: '#f37938'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ complete: function () {}
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- // 调用 API 解析地址
|
|
|
- wx.request({
|
|
|
- url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
- data: {},
|
|
|
- header: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- success: (ops) => { // 使用箭头函数
|
|
|
- console.log(ops);
|
|
|
- const address = ops.data.result.formatted_address;
|
|
|
- this.setData({
|
|
|
- address: address,
|
|
|
- });
|
|
|
- console.log(this.data.address);
|
|
|
- },
|
|
|
- fail: function (resq) {
|
|
|
- wx.showModal({
|
|
|
- title: '信息提示',
|
|
|
- content: '请求失败',
|
|
|
- showCancel: false,
|
|
|
- confirmColor: '#f37938'
|
|
|
- });
|
|
|
- },
|
|
|
- complete: function () {}
|
|
|
- });
|
|
|
},
|
|
|
})
|