Authored by 黄敬囿

Merge branch 'feature/dev-6.9.19' into 'master'

Feature/dev 6.9.19

订阅消息

See merge request !20
1 import { jumpByUrl } from '../../libs/urlRoute'; 1 import { jumpByUrl } from '../../libs/urlRoute';
2 -import { postFormId } from '../../libs/formIdCollectRequest.js';  
3 2
4 import { 3 import {
5 yasReport, 4 yasReport,
@@ -51,11 +50,5 @@ Component({ @@ -51,11 +50,5 @@ Component({
51 jumpByUrl(that.properties.url,'home'); 50 jumpByUrl(that.properties.url,'home');
52 that.hideDialog(); 51 that.hideDialog();
53 }, 52 },
54 - //formId上报  
55 - formSubmit(e) {  
56 - // console.log('----formSubmit---', e);  
57 - let formId = e.detail.formId;  
58 - postFormId(formId,'1');  
59 - }  
60 } 53 }
61 }) 54 })
1 <view class='container' hidden="{{!isShow}}" catchtouchmove="true"> 1 <view class='container' hidden="{{!isShow}}" catchtouchmove="true">
2 <view class='dialog-mask'> 2 <view class='dialog-mask'>
3 <view class='dialog'> 3 <view class='dialog'>
4 - <form bindsubmit='formSubmit' report-submit='true'>  
5 <image src="{{src}}" class='dialog-image' mode='aspecdtFit' bindtap='jumpByRule'></image> 4 <image src="{{src}}" class='dialog-image' mode='aspecdtFit' bindtap='jumpByRule'></image>
6 - <button class='image-btn' form-type='submit' bindtap='jumpByRule'></button>  
7 - </form>  
8 - <form bindsubmit='formSubmit' report-submit='true'> 5 + <button class='image-btn' bindtap='jumpByRule'></button>
9 <view class='dialog-close' bindtap='hideDialog'> 6 <view class='dialog-close' bindtap='hideDialog'>
10 <image class='close' src="./images/close.png" ></image> 7 <image class='close' src="./images/close.png" ></image>
11 - <button class='dialog-btn' form-type='submit'></button> 8 + <button class='dialog-btn'></button>
12 </view> 9 </view>
13 - </form>  
14 </view> 10 </view>
15 </view> 11 </view>
16 </view> 12 </view>
1 -  
2 -import Promise from '../vendors/es6-promise';  
3 -import { API_HOST, SERVICE_HOST } from './config';  
4 -import { GET, POST } from './request';  
5 -import { getYHStorageSync } from '../utils/util';  
6 -  
7 -function postFormId(formId,position) {  
8 - let app = getApp();  
9 - let that = this;  
10 - //如果没有uid,不上报,否则接口报500  
11 - if (!app.getUid()||formId.length===0) return  
12 - if(!position) position=''  
13 - let formIdParams = {  
14 - uid: app.getUid(),  
15 - openId: app.globalData.openID ? app.globalData.openID : getYHStorageSync('openID', 'goodsDetail'),  
16 - miniapp_type: app.globalData.miniapp_type,  
17 - formId: formId,  
18 - position,  
19 - method: 'wechat.formId.add',  
20 - }  
21 -  
22 - // console.log('formidParam:', formIdParams)  
23 - GET(API_HOST, formIdParams)  
24 - .then((data) => {  
25 - // console.log('responsedata', data)  
26 - })  
27 - .catch(error => {  
28 - })  
29 -}  
30 -  
31 -export {  
32 - postFormId,  
33 -}  
  1 +
  2 +import { API_HOST, SERVICE_HOST } from './config';
  3 +import { GET, POST } from './request';
  4 +
  5 +function postTmplId(params) {
  6 + let app = getApp();
  7 + let that = this;
  8 + //如果没有uid,不上报,否则接口报500
  9 + if (!app.getUid() || params.tmplIds.length === 0) return
  10 + return new Promise(resolve => {
  11 + wx.requestSubscribeMessage({
  12 + tmplIds: params.tmplIds,
  13 + success(res) {
  14 + console.log(res)
  15 + let tmplIds = res
  16 + delete tmplIds.errMsg
  17 + tmplIds = JSON.stringify(tmplIds)
  18 + //上报tmplIds
  19 + let tmplIdParams = {
  20 + uid: app.getUid(),
  21 + openId: app.getOpenID(),
  22 + miniAppType: app.globalData.miniapp_type,
  23 + templateIds: tmplIds,
  24 + method: 'mini.subscribe.add',
  25 + }
  26 + console.log('params', tmplIdParams)
  27 + GET(API_HOST, tmplIdParams).then(res => {
  28 + resolve(res)
  29 + })
  30 + },
  31 + fail(res) {
  32 + console.log(res)
  33 + wx.showToast({
  34 + title: res.errCode===20004 ? '消息未开启 请点击右上角,打开设置,开启消息': res.errMsg,
  35 + icon: 'none',
  36 + duration: 3000,
  37 + })
  38 + setTimeout(function() {
  39 + resolve()
  40 + }, 3000)
  41 + }
  42 + })
  43 + })
  44 +
  45 +}
  46 +
  47 +export {
  48 + postTmplId,
  49 +}
1 // page/subPackage/pages/zeroSell/components/action-bar.js 1 // page/subPackage/pages/zeroSell/components/action-bar.js
2 2
3 import ZeroSellService from '../service/zero-sell' 3 import ZeroSellService from '../service/zero-sell'
4 -import CommonService from '../service/common'  
5 import router from '../router/router' 4 import router from '../router/router'
6 - 5 +import { postTmplId } from '../../../libs/tmplIdMessage.js'
7 const event = global.event; 6 const event = global.event;
8 7
9 var app = getApp(); 8 var app = getApp();
@@ -50,18 +49,23 @@ Component({ @@ -50,18 +49,23 @@ Component({
50 show: false, 49 show: false,
51 code: '', 50 code: '',
52 error: false, 51 error: false,
53 - fellow: false 52 + fellow: false,
  53 + msgChecked: true
54 }, 54 },
55 55
56 ready() { 56 ready() {
57 this.service = new ZeroSellService(); 57 this.service = new ZeroSellService();
58 - this.commonService = new CommonService();  
59 }, 58 },
60 59
61 /** 60 /**
62 * 组件的方法列表 61 * 组件的方法列表
63 */ 62 */
64 methods: { 63 methods: {
  64 + msgSwitch() {
  65 + this.setData({
  66 + msgChecked: !this.data.msgChecked
  67 + })
  68 + },
65 fetchCode() { 69 fetchCode() {
66 wx.showLoading({ 70 wx.showLoading({
67 mask: true 71 mask: true
@@ -104,8 +108,22 @@ Component({ @@ -104,8 +108,22 @@ Component({
104 }, 108 },
105 109
106 hadJoinToShare() { 110 hadJoinToShare() {
107 - this.goShare();  
108 - this.triggerEvent('getcode'); 111 + console.log(this.data.msgChecked)
  112 + let that = this
  113 + if (this.data.msgChecked) {
  114 + let tmplIds = ['2PMsn85-733813unyw1EGVLQY5LE6BbHIQ_sGM-F-3U', 'l3YAeDrrqspEFpNpOofZxXAk_wKH3zdjNBVZmX42q5c'];
  115 + postTmplId({
  116 + tmplIds
  117 + }).then(res => {
  118 + that.goShare();
  119 + that.triggerEvent('getcode');
  120 + }).catch(err => {
  121 + console.log(err)
  122 + })
  123 + } else {
  124 + this.goShare();
  125 + this.triggerEvent('getcode');
  126 + }
109 }, 127 },
110 128
111 goMyList() { 129 goMyList() {
@@ -152,13 +170,5 @@ Component({ @@ -152,13 +170,5 @@ Component({
152 this.triggerEvent('getcode'); 170 this.triggerEvent('getcode');
153 }, 171 },
154 172
155 - submitFormId(e) {  
156 - return this.commonService.addWechatFormId({  
157 - formId: e.detail.formId,  
158 - uid: app.getUid() || 0,  
159 - openId: app.getOpenID() || '',  
160 - miniapp_type: app.getMiniappType()  
161 - });  
162 - }  
163 } 173 }
164 }) 174 })
@@ -52,7 +52,6 @@ @@ -52,7 +52,6 @@
52 </block> 52 </block>
53 </block> 53 </block>
54 </view> 54 </view>
55 -  
56 <new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert"> 55 <new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert">
57 <view class="code-alert"> 56 <view class="code-alert">
58 <text class="code-title">参加抽奖成功</text> 57 <text class="code-title">参加抽奖成功</text>
@@ -60,10 +59,16 @@ @@ -60,10 +59,16 @@
60 <view class="title">你的抽奖码是</view> 59 <view class="title">你的抽奖码是</view>
61 <view class="code">{{code}}</view> 60 <view class="code">{{code}}</view>
62 </view> 61 </view>
63 - <form bindsubmit='submitFormId' report-submit='true'>  
64 - <button class="share" form-type="submit" bindtap="hadJoinToShare">分享一下,中奖概率立马double</button>  
65 - </form> 62 + <button class="share" bindtap="hadJoinToShare">分享一下,中奖概率立马double</button>
66 <view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view> 63 <view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
  64 + <!-- <radio class="radio" value="{{msgChecked}}" bindtap="msgSwitch" color="#979797" checked="{{msgChecked}}">
  65 + <text>同意接收开奖结果通知</text>
  66 + </radio> -->
  67 + <label class="radio-box" for="{{msgChecked}}" bindtap="msgSwitch">
  68 + <radio hidden value="{{msgChecked}}" checked="{{msgChecked}}"/>
  69 + <image class="radio" src="../../../images/default-{{msgChecked ? 'select' : 'normal'}}@3x.png"></image>
  70 + <text>同意接收开奖结果通知</text>
  71 + </label>
67 </view> 72 </view>
68 </new-lucky-alert> 73 </new-lucky-alert>
69 74
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 } 63 }
64 64
65 .code-bg { 65 .code-bg {
66 - margin-top: 80rpx; 66 + margin-top: 50rpx;
67 display: flex; 67 display: flex;
68 flex-direction: row; 68 flex-direction: row;
69 align-items: center; 69 align-items: center;
@@ -154,3 +154,17 @@ @@ -154,3 +154,17 @@
154 font-size: 30rpx; 154 font-size: 30rpx;
155 padding: 0 100rpx; 155 padding: 0 100rpx;
156 } 156 }
  157 +.radio-box {
  158 + width: 460rpx;
  159 + text-align: left;
  160 + font-size: 24rpx;
  161 + color: #444;
  162 + display: flex;
  163 + line-height: 38rpx;
  164 + margin-top: 10rpx;
  165 +}
  166 +.radio {
  167 + width: 38rpx;
  168 + height: 38rpx;
  169 + margin-right: 10rpx;
  170 +}
@@ -78,16 +78,7 @@ Component({ @@ -78,16 +78,7 @@ Component({
78 tabs 78 tabs
79 }); 79 });
80 }, 80 },
81 - submitFormId(e) {  
82 - if (app.getUid()) {  
83 - this.commonService.addWechatFormId({  
84 - formId: e.detail.formId,  
85 - uid: app.getUid() || 0,  
86 - openId: app.getOpenID() || '',  
87 - miniapp_type: app.getMiniappType()  
88 - })  
89 - }  
90 - } 81 +
91 }, 82 },
92 83
93 ready() { 84 ready() {
1 <!--page/subPackage/pages/zeroSell/components/tabs.wxml--> 1 <!--page/subPackage/pages/zeroSell/components/tabs.wxml-->
2 -<form bindsubmit='submitFormId' report-submit='true'>  
3 <view class="tabs tabs-class"> 2 <view class="tabs tabs-class">
4 <block wx:for="{{tabs}}" wx:key="{{index}}"> 3 <block wx:for="{{tabs}}" wx:key="{{index}}">
5 <block wx:if="{{item.active}}"> 4 <block wx:if="{{item.active}}">
6 - <button form-type="submit" class="tab active" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button> 5 + <button class="tab active" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
7 </block> 6 </block>
8 7
9 <block wx:else> 8 <block wx:else>
10 - <button form-type="submit" class="tab" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button> 9 + <button class="tab" data-index="{{index}}" bindtap="_onTap">{{item.name}}</button>
11 </block> 10 </block>
12 </block> 11 </block>
13 </view> 12 </view>
14 -</form> 13 +
15 <slot></slot> 14 <slot></slot>
@@ -180,15 +180,6 @@ Component({ @@ -180,15 +180,6 @@ Component({
180 this.triggerEvent('changeStatus'); 180 this.triggerEvent('changeStatus');
181 }, 181 },
182 182
183 - submitFormId(e) {  
184 - return this.commonService.addWechatFormId({  
185 - formId: e.detail.formId,  
186 - uid: app.getUid() || 0,  
187 - openId: app.getOpenID() || '',  
188 - miniapp_type: app.getMiniappType(),  
189 - });  
190 - },  
191 -  
192 goLogin() { 183 goLogin() {
193 const event = global.event; 184 const event = global.event;
194 event.emit('user-is-login', { 185 event.emit('user-is-login', {
@@ -41,11 +41,10 @@ @@ -41,11 +41,10 @@
41 <view class="title">你的抽奖码是</view> 41 <view class="title">你的抽奖码是</view>
42 <view class="code">{{code}}</view> 42 <view class="code">{{code}}</view>
43 </view> 43 </view>
44 - <form bindsubmit='submitFormId' report-submit='true'>  
45 - <button open-type="share" class="share" form-type="submit" bindtap="hadJoinToShare"> 44 + <button open-type="share" class="share" bindtap="hadJoinToShare">
46 分享一下,中奖概率立马double 45 分享一下,中奖概率立马double
47 </button> 46 </button>
48 - </form> 47 +
49 <view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view> 48 <view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
50 </view> 49 </view>
51 </new-lucky-alert> 50 </new-lucky-alert>
@@ -9,12 +9,6 @@ class CommonService extends Service { @@ -9,12 +9,6 @@ class CommonService extends Service {
9 super(); 9 super();
10 } 10 }
11 11
12 - addWechatFormId(data) {  
13 - return this._get(API_HOST, Object.assign({  
14 - method: 'wechat.formId.add'  
15 - }, data))  
16 - }  
17 -  
18 getResourceCode(content_code) { 12 getResourceCode(content_code) {
19 let param = { 13 let param = {
20 content_code 14 content_code
@@ -32,6 +32,10 @@ @@ -32,6 +32,10 @@
32 "current": -1, 32 "current": -1,
33 "list": [] 33 "list": []
34 }, 34 },
  35 + "gamePlugin": {
  36 + "current": -1,
  37 + "list": []
  38 + },
35 "miniprogram": { 39 "miniprogram": {
36 "current": 6, 40 "current": 6,
37 "list": [ 41 "list": [
@@ -91,6 +95,13 @@ @@ -91,6 +95,13 @@
91 "query": "actPrizeId=62&fromPageParam=1&tabIdx=1", 95 "query": "actPrizeId=62&fromPageParam=1&tabIdx=1",
92 "scene": 1036, 96 "scene": 1036,
93 "referrerInfo": {} 97 "referrerInfo": {}
  98 + },
  99 + {
  100 + "id": -1,
  101 + "name": "pages/zeroSell/detail",
  102 + "pathName": "pages/zeroSell/detail",
  103 + "query": "actPrizeId=116&fromPageParam=1&tabIdx=1",
  104 + "scene": null
94 } 105 }
95 ] 106 ]
96 } 107 }