Authored by baoss

删除模板消息 新增订阅消息 review by bevishuang

import { jumpByUrl } from '../../libs/urlRoute';
import { postFormId } from '../../libs/formIdCollectRequest.js';
import {
yasReport,
... ... @@ -51,11 +50,5 @@ Component({
jumpByUrl(that.properties.url,'home');
that.hideDialog();
},
//formId上报
formSubmit(e) {
// console.log('----formSubmit---', e);
let formId = e.detail.formId;
postFormId(formId,'1');
}
}
})
\ No newline at end of file
... ...
<view class='container' hidden="{{!isShow}}" catchtouchmove="true">
<view class='dialog-mask'>
<view class='dialog'>
<form bindsubmit='formSubmit' report-submit='true'>
<image src="{{src}}" class='dialog-image' mode='aspecdtFit' bindtap='jumpByRule'></image>
<button class='image-btn' form-type='submit' bindtap='jumpByRule'></button>
</form>
<form bindsubmit='formSubmit' report-submit='true'>
<button class='image-btn' bindtap='jumpByRule'></button>
<view class='dialog-close' bindtap='hideDialog'>
<image class='close' src="./images/close.png" ></image>
<button class='dialog-btn' form-type='submit'></button>
<button class='dialog-btn'></button>
</view>
</form>
</view>
</view>
</view>
\ No newline at end of file
... ...
// 线上环境
export const API_HOST = 'https://api.yoho.cn';
export const SERVICE_HOST = 'https://api.yoho.cn';
export const ACTIVITY_HOST = 'https://action.yoho.cn';
// export const API_HOST = 'https://api.yoho.cn';
// export const SERVICE_HOST = 'https://api.yoho.cn';
// export const ACTIVITY_HOST = 'https://action.yoho.cn';
export const APP_REPORT_HOST = 'https://app.yoho.cn/collect/v3';
export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile';
export const ICONFIG_HOST = 'https://iconfig.yoho.cn/miniapp/v1/';
// 测试环境
// export const API_HOST = 'http://api-test3.dev.yohocorp.com';
// export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com';
// export const ACTIVITY_HOST = 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com';
export const API_HOST = 'http://api-test3.dev.yohocorp.com';
export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com';
export const ACTIVITY_HOST = 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com';
// export const APP_REPORT_HOST = 'http://app.yoho.cn/collect/v3';
// export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile';
// export const ICONFIG_HOST = 'http://iconfig.yoho.cn/miniapp/v1/';
... ...
import Promise from '../vendors/es6-promise';
import { API_HOST, SERVICE_HOST } from './config';
import { GET, POST } from './request';
import { getYHStorageSync } from '../utils/util';
function postFormId(formId,position) {
let app = getApp();
let that = this;
//如果没有uid,不上报,否则接口报500
if (!app.getUid()||formId.length===0) return
if(!position) position=''
let formIdParams = {
uid: app.getUid(),
openId: app.globalData.openID ? app.globalData.openID : getYHStorageSync('openID', 'goodsDetail'),
miniapp_type: app.globalData.miniapp_type,
formId: formId,
position,
method: 'wechat.formId.add',
}
// console.log('formidParam:', formIdParams)
GET(API_HOST, formIdParams)
.then((data) => {
// console.log('responsedata', data)
})
.catch(error => {
})
}
export {
postFormId,
}
\ No newline at end of file
import { API_HOST, SERVICE_HOST } from './config';
import { GET, POST } from './request';
function postTmplId(params) {
let app = getApp();
let that = this;
//如果没有uid,不上报,否则接口报500
if (!app.getUid() || params.tmplIds.length === 0) return
return new Promise(resolve => {
wx.requestSubscribeMessage({
tmplIds: params.tmplIds,
success(res) {
console.log(res)
let tmplIds = res
delete tmplIds.errMsg
tmplIds = JSON.stringify(tmplIds)
//上报tmplIds
let tmplIdParams = {
uid: app.getUid(),
openId: app.getOpenID(),
miniAppType: app.globalData.miniapp_type,
templateIds: tmplIds,
method: 'mini.subscribe.add',
}
console.log('params', tmplIdParams)
GET(API_HOST, tmplIdParams).then(res => {
resolve(res)
})
},
fail(res) {
console.log(res)
wx.showToast({
title: res.errCode===20004 ? '消息未开启 请点击右上角,打开设置,开启消息': res.errMsg,
icon: 'none',
duration: 3000,
})
setTimeout(function() {
resolve()
}, 3000)
}
})
})
}
export {
postTmplId,
}
\ No newline at end of file
... ...
// page/subPackage/pages/zeroSell/components/action-bar.js
import ZeroSellService from '../service/zero-sell'
import CommonService from '../service/common'
import router from '../router/router'
import { postTmplId } from '../../../libs/tmplIdMessage.js'
const event = global.event;
var app = getApp();
... ... @@ -50,18 +49,23 @@ Component({
show: false,
code: '',
error: false,
fellow: false
fellow: false,
msgChecked: true
},
ready() {
this.service = new ZeroSellService();
this.commonService = new CommonService();
},
/**
* 组件的方法列表
*/
methods: {
msgSwitch() {
this.setData({
msgChecked: !this.data.msgChecked
})
},
fetchCode() {
wx.showLoading({
mask: true
... ... @@ -104,8 +108,22 @@ Component({
},
hadJoinToShare() {
this.goShare();
this.triggerEvent('getcode');
console.log(this.data.msgChecked)
let that = this
if (this.data.msgChecked) {
let tmplIds = ['2PMsn85-733813unyw1EGVLQY5LE6BbHIQ_sGM-F-3U', 'l3YAeDrrqspEFpNpOofZxXAk_wKH3zdjNBVZmX42q5c'];
postTmplId({
tmplIds
}).then(res => {
that.goShare();
that.triggerEvent('getcode');
}).catch(err => {
console.log(err)
})
} else {
this.goShare();
this.triggerEvent('getcode');
}
},
goMyList() {
... ... @@ -152,13 +170,5 @@ Component({
this.triggerEvent('getcode');
},
submitFormId(e) {
return this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getOpenID() || '',
miniapp_type: app.getMiniappType()
});
}
}
})
... ...
... ... @@ -52,7 +52,6 @@
</block>
</block>
</view>
<new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert">
<view class="code-alert">
<text class="code-title">参加抽奖成功</text>
... ... @@ -60,10 +59,16 @@
<view class="title">你的抽奖码是</view>
<view class="code">{{code}}</view>
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<button class="share" form-type="submit" bindtap="hadJoinToShare">分享一下,中奖概率立马double</button>
</form>
<button class="share" bindtap="hadJoinToShare">分享一下,中奖概率立马double</button>
<view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
<!-- <radio class="radio" value="{{msgChecked}}" bindtap="msgSwitch" color="#979797" checked="{{msgChecked}}">
<text>同意接收开奖结果通知</text>
</radio> -->
<label class="radio-box" for="{{msgChecked}}" bindtap="msgSwitch">
<radio hidden value="{{msgChecked}}" checked="{{msgChecked}}"/>
<image class="radio" src="../../../images/default-{{msgChecked ? 'select' : 'normal'}}@3x.png"></image>
<text>同意接收开奖结果通知</text>
</label>
</view>
</new-lucky-alert>
... ...
... ... @@ -63,7 +63,7 @@
}
.code-bg {
margin-top: 80rpx;
margin-top: 50rpx;
display: flex;
flex-direction: row;
align-items: center;
... ... @@ -154,3 +154,17 @@
font-size: 30rpx;
padding: 0 100rpx;
}
.radio-box {
width: 460rpx;
text-align: left;
font-size: 24rpx;
color: #444;
display: flex;
line-height: 38rpx;
margin-top: 10rpx;
}
.radio {
width: 38rpx;
height: 38rpx;
margin-right: 10rpx;
}
\ No newline at end of file
... ...
... ... @@ -78,16 +78,7 @@ Component({
tabs
});
},
submitFormId(e) {
if (app.getUid()) {
this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getOpenID() || '',
miniapp_type: app.getMiniappType()
})
}
}
},
ready() {
... ...
<!--page/subPackage/pages/zeroSell/components/tabs.wxml-->
<form bindsubmit='submitFormId' report-submit='true'>
<view class="tabs tabs-class">
<block wx:for="{{tabs}}" wx:key="{{index}}">
<block wx:if="{{item.active}}">
<button form-type="submit" class="tab active" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
<button class="tab active" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
</block>
<block wx:else>
<button form-type="submit" class="tab" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
<button class="tab" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
</block>
</block>
</view>
</form>
<slot></slot>
\ No newline at end of file
... ...
... ... @@ -180,15 +180,6 @@ Component({
this.triggerEvent('changeStatus');
},
submitFormId(e) {
return this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getOpenID() || '',
miniapp_type: app.getMiniappType(),
});
},
goLogin() {
const event = global.event;
event.emit('user-is-login', {
... ...
... ... @@ -41,11 +41,10 @@
<view class="title">你的抽奖码是</view>
<view class="code">{{code}}</view>
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<button open-type="share" class="share" form-type="submit" bindtap="hadJoinToShare">
<button open-type="share" class="share" bindtap="hadJoinToShare">
分享一下,中奖概率立马double
</button>
</form>
<view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
</view>
</new-lucky-alert>
... ...
... ... @@ -9,12 +9,6 @@ class CommonService extends Service {
super();
}
addWechatFormId(data) {
return this._get(API_HOST, Object.assign({
method: 'wechat.formId.add'
}, data))
}
getResourceCode(content_code) {
let param = {
content_code
... ...
... ... @@ -32,6 +32,10 @@
"current": -1,
"list": []
},
"gamePlugin": {
"current": -1,
"list": []
},
"miniprogram": {
"current": 6,
"list": [
... ... @@ -91,6 +95,13 @@
"query": "actPrizeId=62&fromPageParam=1&tabIdx=1",
"scene": 1036,
"referrerInfo": {}
},
{
"id": -1,
"name": "pages/zeroSell/detail",
"pathName": "pages/zeroSell/detail",
"query": "actPrizeId=116&fromPageParam=1&tabIdx=1",
"scene": null
}
]
}
... ...