123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- const _Http = getApp().globalData.http,
- MFT = require("../../utils/matchingFeilType"),
- checkFile = require("../../utils/checkFile");
- import Dialog from '@vant/weapp/dialog/dialog';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- sat_sharematerialid: null,
- detailsData: {},
- dataType: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- this.setData({
- dataType: options.type,
- sat_sharematerialid: options.id
- })
- let isToken = wx.getStorageSync('userMsg').token; //判断是否为无状态进入
- const params = {
- "classname": "saletool.sharematerial.sharematerial",
- "method": isToken ? "selectDetail" : "selectDetailNoToken",
- "content": {
- "sat_sharematerialid": options.id
- }
- };
- const res = isToken ? await _Http.basic(params) : await _Http.base(params);
- if (res.msg != '成功') res = await _Http.base(params);
- if (res.msg == '成功') {
- if (res.data.attinfos.length) res.data.attinfos = MFT.fileList(res.data.attinfos);
- this.setData({
- detailsData: res.data
- });
- //分享进入
- if (wx.getLaunchOptionsSync().scene == 1154) {
- this.addNew(false)
- } else if ([1007, 1008].includes(wx.getLaunchOptionsSync().scene)) Dialog.confirm({
- title: '提示',
- message: '请帮助完善信息',
- })
- .then(this.addNew)
- .catch(this.addNew)
- } else {
- wx.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- },
- /* 新增拉新用户 */
- async addNew(gain = true) {
- let name = '微信用户';
- if (gain) name = await new Promise((res, rej) => {
- wx.getUserProfile({
- desc: '用于完善用户资料',
- success: ({
- userInfo
- }) => {
- res(userInfo.nickName)
- },
- fail: () => {
- res('微信用户')
- }
- })
- })
- let channel = null,
- that = this;
- switch (wx.getLaunchOptionsSync().scene) {
- case 1007:
- channel = '单人会话分享'
- break;
- case 1008:
- channel = '群聊会话分享'
- break;
- case 1154:
- channel = '朋友圈分享'
- break;
- default:
- channel = '其他方式'
- break;
- }
- wx.login({
- success(res) {
- _Http.base({
- "classname": "saletool.sharematerial.sharematerial",
- "method": "addNew",
- "content": {
- "sat_sharematerialid": that.data.sat_sharematerialid,
- "fname": name,
- "channel": channel,
- "code": res.code,
- "systemclient": "wechatsaletool"
- }
- }, false).then(res => {
- console.log("记录分享", res)
- })
- }
- })
- },
- openFile(e) {
- checkFile.checkFile(e.currentTarget.dataset.item);
- },
- updateShareLog(id) {
- _Http.basic({
- "classname": "saletool.sharematerial.sharematerial",
- "method": "updateShareLog",
- "content": {
- "sat_sharematerialid": id,
- "channel": "wechat"
- }
- })
- this.setData({
- 'detailsData.sharecount': this.data.detailsData.sharecount + 1
- })
- },
- onShareAppMessage() {
- const promise = new Promise(resolve => {
- let data = this.data.detailsData;
- this.updateShareLog(data.sat_sharematerialid);
- resolve({
- title: data.title,
- path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}`,
- imageUrl: data.cover
- })
- })
- return {
- promise
- }
- },
- onShareTimeline: function () {
- let data = this.data.detailsData;
- return {
- title: data.title,
- path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}`,
- imageUrl: data.cover
- }
- }
- })
|