channel.js 545 Bytes
// 渠道本地缓存KEY
const storageKeyChannel = 'CHANNEL_FROM';

// 默认渠道ID
const defaultChannel = '1';

module.exports = {

  /**
   * 设置渠道
   */
  setChannel: function (options) {
    var channel = options.channel || wx.getStorageSync(storageKeyChannel);
    if (!channel) {
      channel = defaultChannel;
    }
    wx.setStorageSync(storageKeyChannel, channel);
  },

  /**
   * 获取渠道
   */
  getChannel: function () {
    return wx.getStorageSync(storageKeyChannel) || defaultChannel;
  }
}