123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // pages/subscription/index.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- warrantFlag:false,
- wxList: [],
- pages: 1,
- page: 1
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function () {
- this.getList();
- },
- goWarrant(){//去授权
- this.setData({
- warrantFlag:true
- })
- },
- closeToast(){
- this.setData({
- warrantFlag:false
- })
- },
- getList(e) {
- wx.showLoading({
- title: '加载中',
- })
- e&&(this.setData({
- page: 1,
- wxList: []
- }))
- app.func.req('/api/account/index', 'get',{
- page: this.data.page,
- page_size: 20,
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- //成功
- this.setData({
- wxList: this.data.wxList.concat(res.rst.data),
- page: res.rst.pageInfo.page,
- pages: res.rst.pageInfo.pages,
- })
- }else {
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.setData({
- page:Number(this.data.page)+1
- })
- if(this.data.pages>=this.data.page) {
- this.getList();
- }
- },
- // 选择公众号
- toCheck(e) {
- if(e.currentTarget.dataset.item.is_checked==1) {
- return;
- }
- app.func.req('/api/account/checked', 'post', {
- 'app_id': e.currentTarget.dataset.item.app_id
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- //成功
- wx.showToast({
- title: '切换公众号成功',
- })
- this.setData({
- wxList: [],
- page: 1
- })
- this.getList();
- }else {
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- toCustom() {
- this.setData({
- warrantFlag: false
- })
- },
- onShareAppMessage() {
-
- }
- })
|