Sanakey
2020-11-06 65c4a68484a8d6fee25d3bb94bb7a24da6dfc147
优化小程序页面加载速度
11个文件已修改
149 ■■■■■ 已修改文件
app.js 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.json 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
component/shareGoodsPoster/index.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ext.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/cart/cart.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/classify2/classify2.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/classify2/classify2.wxml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/refund/refund.js 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/refund/refund.wxml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.config.json 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.js
@@ -4,7 +4,7 @@
import { Request } from './utils/http'
import { updateManager } from './utils/appExtends'
import {webSocket, socketReconnect} from './utils/websocket'
// let livePlayer = requirePlugin('live-player-plugin');
let livePlayer = requirePlugin('live-player-plugin');
// promisify all wx‘s api
promisifyAll();
@@ -97,6 +97,7 @@
  },
  appOnLoad(){
console.log('开始发送setting请求');
    this.getSettings().then((res) => {
@@ -241,6 +242,7 @@
          this.globalData.isAllowSelectDeliveryMethod = res.data.isAllowSelectDeliveryMethod||false;
          this.globalData.deliveryMethod = res.data.deliveryMethod||'';
          this.globalData.isShowBannerPhotoOnHomePageForLiveUser = res.data.isShowBannerPhotoOnHomePageForLiveUser||false;
          this.globalData.isShowMatGroupInHomePage = res.data.isShowMatGroupInHomePage||false;
          resolve(res);
        },
@@ -752,17 +754,17 @@
    // 直播间
    if((options.scene == 1007 || options.scene == 1008 || options.scene == 1044)&&options.path.includes('/pages/live-player-plugin')){
      console.log('通过直播分享卡片进入小程序', options);
      // livePlayer.getShareParams()
      // .then((res)=>{
      //   console.log('获取直播 room id', res.room_id); // 房间号
      //   console.log('获取直播 openid', res.openid); // 用户openid
      //   console.log('获取直播 share openid', res.share_openid); // 分享者openid,分享卡片进入场景才有
      //   console.log('获取 custom params', res.custom_params); // 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
      //   let FromUserId = res.custom_params.FromUserId || '';
      //   this.handleFromUserIdChange(FromUserId);
      // }).catch(err => {
      //   console.log('获取直播 share params', err)
      // })
      livePlayer.getShareParams()
      .then((res)=>{
        console.log('获取直播 room id', res.room_id); // 房间号
        console.log('获取直播 openid', res.openid); // 用户openid
        console.log('获取直播 share openid', res.share_openid); // 分享者openid,分享卡片进入场景才有
        console.log('获取 custom params', res.custom_params); // 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
        let FromUserId = res.custom_params.FromUserId || '';
        this.handleFromUserIdChange(FromUserId);
      }).catch(err => {
        console.log('获取直播 share params', err)
      })
    }
    // 不是初次打开
    else if(!this.isFirstOpenApp){
app.json
@@ -138,7 +138,10 @@
    }
  },
  "plugins": {
    "live-player-plugin": {
      "version": "1.2.2",
      "provider": "wx2b03c6e691cd7370"
    },
    "chooseLocation": {
      "version": "1.0.5",
      "provider": "wx76a9a06e5b4e693e"
component/shareGoodsPoster/index.js
@@ -122,13 +122,18 @@
      let posterCreate =  this.selectComponent('#posterCreate');
      posterCreate.formSubmit(e);
    },
    compressImg(img){
      // let img = this.data.goodsItemImg;
      let lastIndex = img.lastIndexOf('.');
      let ext = img.substring(lastIndex);
      let noext = img.slice(0,lastIndex);
      return noext.split('_')[0]+'_360x360'+ext
    },
    downloadFile(){
      console.log(app.globalData.cardUserData)
      console.log('头像',app.globalData.cardUserData.Avatar)
      // console.log('logo',app.globalData.logoUrl)
      console.log('二维码',this.data.qrCode)
      console.log('商品',this.data.goodsItemImg)
      console.log('商品',this.compressImg(this.data.goodsItemImg))
      let avatarUrl = wx.pro.downloadFile({
        url: app.globalData.cardUserData.Avatar
      }).then((res)=>{
@@ -141,7 +146,7 @@
        }
      })
      let goodsImg = wx.pro.downloadFile({
        url: this.data.goodsItemImg
        url: this.compressImg(this.data.goodsItemImg)
      }).then((res)=>{
        if (res.statusCode === 200) {
          // imgDownloadSum++;
ext.json
@@ -1,10 +1,10 @@
{
  "extEnable": true,
  "extAppid": "wx50edcb45ab6bfb06",
  "extAppid": "wxec78156626302b78",
  "directCommit": false,
  "ext": {
    "name": "wechat",
    "AppId": "wx50edcb45ab6bfb06",
    "AppId": "wxec78156626302b78",
    "HttpHost": "https://mp.onbus.cn",
    "WssHost": "wss://mp.onbus.cn",
    "FooterNumPosition":3,
pages/cart/cart.js
@@ -655,10 +655,15 @@
    let edit = this.data.goodsList.edit;
    let num = res.data.CartItems || 0;
    if (app.globalData.cartIndex>-1||app.globalData.cartIndex<6) {
      wx.setTabBarBadge({
        index: app.globalData.cartIndex,
        text: num.toString()
      })
      try {
        wx.setTabBarBadge({
          index: app.globalData.cartIndex,
          text: num.toString()
        })
      } catch (error) {
        console.log(error);
      }
    }
    let isAllSelect = false;
    let isNoSelect = false;
pages/classify2/classify2.js
@@ -292,7 +292,9 @@
  async addCartItem(event) {
    const matcode = event.currentTarget.dataset.matcode;
    let [err, res] = await this.addCartItemRequest(matcode);
    const mininum = event.currentTarget.dataset.mininum;
    let [err, res] = await this.addCartItemRequest(matcode,mininum);
    if (err) {
      return;
    }
@@ -304,14 +306,14 @@
    this.updateCartList(res);
    // this.updateGoodsList();
  },
  async addCartItemRequest(matcode) {
  async addCartItemRequest(matcode,mininum) {
    let [err, res] = await utils.to(
      wx.$http.request({
        url: "/shopping/cart.do",
        data: {
          m: "add",
          matcode,
          quantity: 1,
          quantity: mininum||1,
        },
        title:'正在加载'
      })
@@ -410,7 +412,8 @@
    console.log(event);
    const cartId = event.currentTarget.dataset.id;
    let quantity = event.currentTarget.dataset.quantity;
    quantity--;
    let mininum = event.currentTarget.dataset.mininum;
    quantity=quantity-mininum;
    if (quantity <= 0) {
      let [err, res] = await this.deleteCartItem(cartId);
      if (err) {
@@ -427,7 +430,8 @@
    console.log(event);
    const cartId = event.currentTarget.dataset.id;
    let quantity = event.currentTarget.dataset.quantity;
    quantity++;
    let mininum = event.currentTarget.dataset.mininum;
    quantity=quantity+mininum;
    if (cartId) {
      await this.sendCartItemChange(cartId, quantity);
    } else {
pages/classify2/classify2.wxml
@@ -20,6 +20,7 @@
        <text class="iconfont icon-sousuo1 search-icon"></text>
    </navigator>
</van-nav-bar> -->
<import src="../template/no-more/no-more-template" />
<view class="search-bar">
    <navigator class="search-box" url="../search/search">
        <view class="search-input">
@@ -95,7 +96,8 @@
                                button-size="26"
                                min="0"
                                integer
                                value="{{ item.selectedQuantity }}"
                                data-mininum="{{item.Mininum||1}}"
                                value="{{item.selectedQuantity}}"
                                async-change
                                bind:plus="onCartItemPlus"
                                bind:minus="onCartItemMinus"
@@ -122,6 +124,7 @@
<!--                <van-tag class="van-tags"  mark type="{{tagTypes[item.LiveStatus]}}">{{liveStatus[item.LiveStatus]}}</van-tag>-->
            </block>
            <c-empty wx:if="{{goodsList.length<1}}" desc="该分类下没有商品"></c-empty>
            <template wx:if="{{currentPage>=TotalPages}}" is="noMoreTemplate" />
        </view>
@@ -197,8 +200,9 @@
                                    input-width="50"
                                    button-size="25"
                                    min="0"
                                    data-mininum="{{item.Mininum||1}}"
                                    integer
                                    value="{{ item.Quantity }}"
                                    value="{{item.Quantity}}"
                                    async-change
                                    bind:plus="onCartItemPlus"
                                    bind:minus="onCartItemMinus"
pages/index/index.js
@@ -84,6 +84,8 @@
    console.log('。。。首页获取的openid与fromuserid',app.globalData.openID,!app.globalData.openID,app.globalData.FromUserId,!app.globalData.FromUserId)
    if (!app.globalData.openID || !app.globalData.FromUserId) {
      app.globalData.indexCallback = (res) => {
        console.log('首页获取setting');
        that.getSetting();
        that.getIndexData();
        this.setData({
@@ -326,6 +328,8 @@
    that.setData({
      navList: [],
    })
    console.log('开始发送图标菜单请求。。。。',that.data.navList, utils.getUrl('/shopping/getHomePageSubMenu.do'))
    
    // 图标菜单
@@ -412,8 +416,9 @@
    });
    // 请求下拉菜单
    console.log('app.globalData.isShowMatGroupInHomePage',app.globalData.isShowMatGroupInHomePage);
    if (app.globalData.isShowMatGroupInHomePage) {
      // 请求下拉菜单
    wx.request({
      url: utils.getUrl('/shopping/getMatGroupInHomePage.do'),
      header: {
@@ -438,10 +443,9 @@
        //   wx.hideLoading();
        // }
      }
    });
  }
    // 首次推荐商品请求
    console.log('开始推荐商品请求。。',utils.getUrl('/shopping/getMatCodeList.do?fromdata=8'))
    wx.request({
pages/refund/refund.js
@@ -9,6 +9,7 @@
var doccode = "";
var rowid = "";
var mIndex = "";
let formid = '';
Page({
@@ -96,24 +97,25 @@
    })
  },
  // inputChange:function(e){
  //   var length = e.detail.value.length;
  //   this.setData({
  //     inputLength:length
  //   })
  // },
  inputChange:function(e){
    let explain = e.detail.value;
    this.setData({
      explain
    })
  },
  // 提交按钮
  submitForm:function(e){
    let reasonid = e.detail.value.why;
    let hdmemo = e.detail.value.explain;
    let reasonid = this.data.index;
    // let reasonid = e.detail.value.why;
    let hdmemo = this.data.explain;
    var that = this;
    var imageList = this.data.imageList;
    console.log(e.detail.value);
    if (e.detail.value.why == null || e.detail.value.why == ""){
    if (reasonid == null || reasonid == ""){
      utils.showTopTips(this,"请选择退款理由");
      return false;
    }
@@ -124,7 +126,7 @@
        // wx.navigateTo({
        //   url: '../orderlistGuide/orderlistGuide',
        // })
        // if (imageList.length==0){
        //   utils.showTopTips(this,"请选择上传图片");
        //   return false;
@@ -173,7 +175,7 @@
      }
    })
@@ -219,7 +221,8 @@
    //   price:sumPrice
    // })
    console.log(options);
    wx.request({
      url: utils.getUrl('/shopping/pay/getReturnReasonList.do'),
pages/refund/refund.wxml
@@ -10,7 +10,7 @@
      <view class="mark">
        {{orderDetail.StatusDesc||""}}
      </view>
    </view>
    <!-- wx:for="{{orderDetail.list}}" wx:key="index" -->
  <view >
@@ -26,7 +26,7 @@
      </view>
    </view>
  </view>
  <form bindsubmit="submitForm">
  <form >
    <picker class="order-picker " bindchange="bindPickerChange" name="why" value="{{reason[index].ReasonId}}" range="{{reason}}" range-key="ReasonName">
      <view class="order-row " >
        <view class="order-row-left">退款理由</view>
@@ -76,8 +76,8 @@
    <view class="weui-cells weui-cells_after-title">
      <view class="weui-cell">
        <view class="weui-cell__bd">
          <textarea class="weui-textarea" placeholder="请输入退款说明(选填)" maxlength="200" name="explain" style="height: 200rpx" bindinput="inputChange" />
          <view class="weui-textarea-counter">{{inputLength||0}}/200</view>
          <textarea class="weui-textarea" placeholder="请输入退款说明(选填)" maxlength="200" name="explain" style="height: 200rpx" bindblur="inputChange" />
<!--          <view class="weui-textarea-counter">{{inputLength||0}}/200</view>-->
        </view>
      </view>
    </view>
@@ -88,7 +88,7 @@
    <!-- <view class="weui-cells__title">上传凭证(最多5张)</view>
    <view class="page-section">
      <view class="weui-cells">
        <view class="weui-cell">
@@ -118,7 +118,7 @@
    </view> -->
    <button type="primary" class="savebtn"  formType="submit">提交</button>
    <button type="primary" class="savebtn"   bindtap="submitForm">提交</button>
  </form>
</view>
</view>
project.config.json
@@ -28,16 +28,18 @@
      "disablePlugins": [],
      "outputPath": ""
    },
    "enableEngineNative": false,
    "useIsolateContext": true,
    "useCompilerModule": true,
    "userConfirmedUseCompilerModuleSwitch": false,
    "packNpmManually": false,
    "packNpmRelationList": []
    "packNpmRelationList": [],
    "minifyWXSS": true
  },
  "compileType": "miniprogram",
  "libVersion": "2.13.1",
  "appid": "wxec78156626302b78",
  "projectname": "ShoppingApp2",
  "projectname": "ShoppingMiniApp",
  "isGameTourist": false,
  "simulatorType": "wechat",
  "simulatorPluginLibVersion": {},
@@ -185,10 +187,9 @@
          "scene": null
        },
        {
          "id": 19,
          "name": "pages/refund/refund",
          "name": "退款",
          "pathName": "pages/refund/refund",
          "query": "id=WXD200320002&&rowid=003RRAX&&index=0",
          "query": "id=WXD200320002&rowid=003RRAX&index=0&formid=120230",
          "scene": null
        },
        {