var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
info: {
mobile: '',
telphone: '',
address: '',
latitude: "",
longitude: "",
},
imgalist: ['https://www.njnrkj.com/MEIRONG/image/contact/code.jpg', 'https://www.njnrkj.com/MEIRONG/image/contact/code.jpg'],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// this.loadInfo();
var that = this
var scene_img = 'https://www.njnrkj.com/MEIRONG/image/contact/code.jpg' //这里添加图片的地址
that.setData({
scene: scene_img
})
},
previewImage: function (e) {
wx.previewImage({
current: this.data.imgalist, // 当前显示图片的http链接
urls: this.data.imgalist // 需要预览的图片http链接列表
})
wx.getImageInfo({// 获取图片信息(此处可不要)
src: 'https://www.njnrkj.com/MEIRONG/image/contact/code.jpg',
success: function (res) {
console.log(res.width)
console.log(res.height)
}
})
},
clickMobile: function () {
wx.makePhoneCall({
phoneNumber: this.data.info.telphone
})
},
clickTelephone: function () {
wx.makePhoneCall({
phoneNumber: this.data.info.mobile
})
},
loadInfo: function () {
var that = this;
var cacheInfo = wx.getStorageSync('info');
if (cacheInfo) {
that.setData({
info: cacheInfo
});
return;
}
wx.request({
url: 'https://www.njnrkj.com/app/public/index.php/index/contact/MrContact',
dataType: 'json',
success: function (res) {
// console.log('res=' + res);
if (res.statusCode == 200 && res.data.error != "error") {
that.setData({
info: res.data.info
});
wx.setStorage({
key: 'info',
data: res.data.info
});
} else {
wx.showToast({
icon: 'none',
title: '没有访问权限或访问出错',
});
}
},
fail: function (err) {
wx.showToast({
icon: 'none',
title: '访问出错',
});
}
})
},
/**
* 地址点击事件
*/
clickAddress: function (e) {
console.log('click address.....');
wx.openLocation({
latitude: 32.0902400000 || 0,
longitude: 118.7813700000 || 0,
name: this.data.info.storeName || '',
address: this.data.info.address || ''
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.loadInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
wx.removeStorage({
key: 'info',
success: function (res) { },
});
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.removeStorageSync('info');
this.loadInfo();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
<view class="container">
<view class="qrcode2"></view>
<image class="codepic" bindtap='previewImage' src ='{{scene}}'></image>
<view class="input-compont">
<view class="address-input">
<view>
<text class='mobile'>手机:{{info.telphone}} </text>
<image bindtap='clickMobile' mode='widthFix' class='img1' src='https://www.njnrkj.com/MEIRONG//image/contact/mobile.png' />
</view>
</view>
<view class="address-input">
<view>
<text>美丽热线:{{info.mobile}} </text>
<image bindtap='clickTelephone' mode='widthFix' class='img2' src='https://www.njnrkj.com/MEIRONG//image/contact/call.png' />
</view>
</view>
<view class="address-input last-input">
<view>
<view class='address_top'>
<text>门店地址:{{info.address}}</text>
<image catchtap='clickAddress' mode='widthFix' class='img3' src='https://www.njnrkj.com/MEIRONG//image/contact/direction.png' />
</view>
</view>
</view>
</view>
</view>