123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- // index.js
- // 获取应用实例
- import http from '../../base/httputil'
- const app = getApp()
- Page({
- data: {
- current: 0, //当前所在页面的 index
- indicatorDots: true, //是否显示面板指示点
- autoplay: true, //是否自动切换
- interval: 3000, //自动切换时间间隔
- duration: 800, //滑动动画时长
- circular: true, //是否采用衔接滑动
- imgUrls: [
- '../images/banner.jpg',
- '../images/banner3.jpg',
- '../images/banner2.jpg'
- ],
- links: [
- // '/pages/second/register',
- // '/pages/second/register',
- // '/pages/second/register'
- ],
- //功能数据-孙一石
- //记录首页点击-登录后继续跳转
- dofun: null
- },
- onLoad() {
- },
- // 待办跳转
- bindViewDaiBan() {
- wx.navigateTo({
- url: '../daiban/daiban'
- })
- },
- // 企业跳转
- bindViewQiYe() {
- wx.navigateTo({
- url: '../qiye/qiye'
- })
- },
- // 巡查跳转
- bindViewXunCha() {
- wx.navigateTo({
- url: '../xuncha/xuncha'
- })
- },
- // 通知公告更多跳转
- bindViewGengDuo() {
- wx.navigateTo({
- url: '../more/more'
- })
- },
- // 新手指南跳转
- bindViewNewComer() {
- wx.navigateTo({
- url: '../newcomer/newcomer',
- })
- },
- //巡检跳转
- bindViewXunJian() {
- wx.navigateTo({
- url: '../xunjian/xunjian',
- })
- },
- // 使用攻略跳转
- bindViewIntroduction() {
- wx.navigateTo({
- url: '../Introduction/Introduction'
- })
- },
- bindViewXunjianimg() {
- wx.navigateTo({
- url: '../xunjianimg/xunjianimg'
- })
- },
- // 图片轮播
- //轮播图的切换事件
- swiperChange: function (e) {
- this.setData({
- swiperCurrent: e.detail.current
- })
- },
- //点击指示点切换
- chuangEvent: function (e) {
- this.setData({
- swiperCurrent: e.currentTarget.id
- })
- },
- //点击图片触发事件
- swipclick: function (e) {
- // console.log(this.data.swiperCurrent);
- wx.switchTab({
- // url: this.data.links[this.data.swiperCurrent]
- })
- },
- //首页功能js-孙一石
- init_userInfo(e) {
- this.data.dofun = e.currentTarget.dataset.fun
- let that = this
- if (app.globalToken == null) {
- http.showLoading()
- wx.getUserProfile({
- desc: 'desc',
- success: (res) => {
- this.getSysUserInfo(res.userInfo)
- },
- fail: res => {
- console.log(res)
- },
- })
- } else {
- this.callByName(this.data.dofun)
- }
- },
- callByName(name) {
- if (name == "bindViewDaiBan") {
- //待办
- this.bindViewDaiBan()
- } else if (name == "bindViewQiYe") {
- //企业
- this.bindViewQiYe()
- } else if (name == "bindViewXunCha") {
- this.bindViewXunCha()
- } else if (name == "bindViewXunjianimg") {
- this.bindViewXunjianimg()
- }
- },
- initIndexPage() {
- http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
- },
- initIndexPageSuccess(res) {
- http.hideLoading()
- },
- loginSuccess(res) {
- if (res.data.code != 200) {
- wx.showToast({
- title: res.data.msg,
- icon: "none"
- })
- } else {
- app.globalToken = res.data.data.access_token
- //登录成功,获取首页数据
- this.initIndexPage()
- }
- console.log("!!!!!", app.globalToken)
- },
- getSysUserInfo(info) {
- let that = this
- wx.login({
- success(res) {
- var code = res.code
- var data = {
- wxCode: code,
- wxNickName: info.nickName,
- wxAvatarUrl: info.avatarUrl
- }
- // http.send_post_login("/minapp/AppLoginController/appLogin",data)
- http.send_post_login("/applogin", data, that.loginSuccess)
- },
- fail(res) {
- console.log("ffff", res)
- }
- })
- }
- })
|