|
|
@@ -0,0 +1,129 @@
|
|
|
+// pages/intro/intro.js
|
|
|
+const app = getApp()
|
|
|
+const host = app.globalData.host;
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ datas:{
|
|
|
+ imgs:[]
|
|
|
+ },
|
|
|
+ type:1
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'userInfo',
|
|
|
+ success: res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.setData({
|
|
|
+ userInfo: res.data
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/article?id=' + options.id,
|
|
|
+ method: 'GET',
|
|
|
+ header: {
|
|
|
+ 'Authorization': this.data.userInfo.token
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: res.data.data.name,
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ data: res.data.data
|
|
|
+ })
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '../user/user',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: error => {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '../user/user',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ init:function(){
|
|
|
+ const query = wx.createSelectorQuery()
|
|
|
+ const that=this
|
|
|
+ query.select('#editor').context(function (res) {
|
|
|
+ res.context.setContents({
|
|
|
+ html: that.data.data.content
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .exec()
|
|
|
+ },
|
|
|
+ openMap:function(){
|
|
|
+ var lon = parseFloat(this.data.data.point.split(',')[0]),
|
|
|
+ lat = parseFloat(this.data.data.point.split(',')[1]);
|
|
|
+ wx.openLocation({//使用微信内置地图查看位置。
|
|
|
+ latitude: lat,//要去的纬度-地址
|
|
|
+ longitude: lon,
|
|
|
+ 'name': '巴中逸沣安全培训'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ phone:function(){
|
|
|
+ wx.makePhoneCall({
|
|
|
+ phoneNumber: this.data.data.phone //仅为示例,并非真实的电话号码
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|