123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // pages/applet/applet.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- title: '',
- app_id: '',
- wxList: [],
- path: '',
- page: 1,
- pages: 1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getList();
- },
- getList(e) {
- wx.showLoading({
- title: '加载中',
- })
- e&&(this.setData({
- page: 1,
- wxList: []
- }))
- app.func.req('/api/weapp/list', '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: Number(res.rst.pageInfo.page),
- pages: res.rst.pageInfo.pages,
- })
- }else {
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- getApp(e) {
- this.setData({
- app_id: e.detail.value
- })
- },
- // 添加小程序
- addPro(e) {
- if(!this.data.app_id) {
- wx.showToast({
- title: '请填写APPID',
- icon: 'none'
- })
- return;
- }
- wx.showLoading({
- title: '加载中',
- })
- app.func.req('/api/weapp/add', 'post',{
- app_id: this.data.app_id,
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- //成功
- wx.showToast({
- title: '添加成功',
- })
- this.setData({
- page: 1,
- wxList: [],
- warrantFlag: false,
- app_id: ''
- })
- this.getList()
- }else {
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- // 选择小程序
- checkPro(e) {
- this.setData({
- itemObj: e.currentTarget.dataset.item
- })
- wx.setStorageSync('itemObj',this.data.itemObj)
- wx.redirectTo({
- url: '/pages/appletEdit/appletEdit'
- })
- },
- goWarrant() {
- this.setData({
- warrantFlag: true
- })
- },
- closeToast(e) {
- this.setData({
- warrantFlag: false,
- app_id: ''
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.setData({
- page: this.data.page+1
- })
- if(this.data.pages>=this.data.page) {
- this.getList();
- }
- },
- onShareAppMessage() {
-
- }
- })
|