tips.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. const util = require('../../utils/util.js');
  2. const app = getApp();
  3. Component({
  4. // properties: {
  5. // isShow: {
  6. // type: Boolean,
  7. // observer: function (newVal, oldVal) {
  8. // this.setData({ isShow: newVal });
  9. // }
  10. // }
  11. // },
  12. data:{
  13. imgUrl:util.config.imgUrl,
  14. tipImg:'',
  15. popupData:{},
  16. popType:1 //1--安全弹窗 2--分享家停用弹窗
  17. },
  18. ready(){
  19. this.innerAudioContext = wx.createInnerAudioContext();
  20. this.innerAudioContext.src = 'http://video.bbztx.com/video/122d3cd2-18994ee8e9b-0000-0000-000-1e90f.mp3';
  21. },
  22. lifetimes:{
  23. moved(){
  24. this.innerAudioContext.stop();
  25. }
  26. },
  27. detached() {
  28. this.innerAudioContext.stop();
  29. },
  30. methods: {
  31. tipsClose(e){
  32. let data = wx.getStorageSync("safeTips") || {},value='';
  33. if (e&&e.currentTarget&&e.currentTarget.dataset.value) {
  34. value=e.currentTarget.dataset.value
  35. }else{
  36. value='';
  37. }
  38. if (value=='popup') {
  39. util.ajax({
  40. func:'v2/sharer/confirm/tips',
  41. }),function (res) {
  42. if (res.code == 0) {
  43. console.log(res.data)
  44. } else {
  45. console.log(res.data)
  46. }
  47. }
  48. }
  49. data.show = false;
  50. this.setData({ isShow : false });
  51. wx.setStorageSync("safeTips", data);
  52. },
  53. audioPlay() {
  54. this.innerAudioContext.stop();
  55. this.innerAudioContext.play();
  56. this.tipsClose();
  57. },
  58. // 点击图片跳转页面(记录点击次数)
  59. jumpPage(){
  60. let data = this.data.popupData,url = '';
  61. let obj ={
  62. cid : data.id,
  63. source : 'applet',
  64. };
  65. util.ajax({
  66. func:'v2/index/advert/popup/click',
  67. data:obj,
  68. method:'post',
  69. load:false
  70. }),function (res) {
  71. if (res.code == 0) {
  72. console.log(res.data)
  73. } else {
  74. console.log(res.data)
  75. }
  76. }
  77. //类目类型 0-单个活动 1-活动集 2-精彩回顾 3-活动体系 4-活动日历 5-活动视频 6-炫酷装备 7-单个链接
  78. switch (data.categoryType){
  79. case 0:
  80. url = '/pages/product/activity/index?aid='+data.aid;
  81. break;
  82. case 1:
  83. url = '/pages/public/swiper/list?id=' + data.id + '&title=' + data.title;
  84. break;
  85. case 2:
  86. url = '/pages/public/wonderful/index';
  87. break;
  88. case 3:
  89. url = '/pages/product/activity/system';
  90. break;
  91. case 4:
  92. url = '/pages/public/calendar/calendar';
  93. break;
  94. case 5:
  95. url = '/pages/public/video/video';
  96. break;
  97. case 6:
  98. url = '/pages/product/goods/index';
  99. break;
  100. case 7:
  101. url = '/pages/public/swiper/web?url=' + encodeURIComponent(data.url) + '&title=' + encodeURIComponent(data.title)
  102. break;
  103. case 8:
  104. url = '/pages/turntable/index?id='+data.wheelId
  105. break;
  106. case 9:
  107. url = '/pages/account/growthCourse/index'
  108. break;
  109. }
  110. this.setData({ isShow : false });
  111. wx.navigateTo({
  112. url: url
  113. });
  114. },
  115. // 安全弹窗数据
  116. getSafeTips(popupData){
  117. let that=this;
  118. util.getUserInfo().then(res=>{
  119. if (res.roleType=='sharer'&& res.roleTypeDisable==1 && res.sharerInfo.showTips==1) {
  120. that.setData({popType:2,isShow:true})
  121. }else{
  122. that.setData({popType:1})
  123. that.safePopup(popupData)
  124. }
  125. },(error)=>{
  126. if (!error) {
  127. that.setData({popType:1})
  128. that.safePopup(popupData)
  129. }
  130. })
  131. },
  132. // 非分享家停用文案内容
  133. safePopup(popupData){
  134. if (popupData.data) {
  135. let TipData = wx.getStorageSync("safeTips");
  136. if (TipData && ((popupData.data && popupData.data.id != TipData.modalId) || TipData.oldHours)) {
  137. wx.removeStorageSync('safeTips')
  138. }
  139. let data = popupData.data;
  140. let newDate = util.getNowFormatDate('yyyy-MM-dd'), safeTipData = wx.getStorageSync("safeTips") || {},newTime = new Date().getTime();
  141. this.setData({ popupData:data});
  142. if (popupData.showPopup && data.area.indexOf(popupData.entryPage) != -1) {
  143. if (util.isObjEmpty(safeTipData) || (util.datedifference(newDate, safeTipData.oldDate) > 0 && safeTipData.todayNum <= data.showCountDay)) {
  144. // this.globalData.openTipsNum = 0;
  145. safeTipData.oldDate = newDate;
  146. safeTipData.num = (safeTipData.num ? safeTipData.num : 0) + 1;
  147. safeTipData.todayNum = 1;
  148. safeTipData.modalId = data.id;
  149. safeTipData.oldTime = newTime;
  150. safeTipData.show = true;
  151. this.setData({ isShow : safeTipData.show });
  152. } else if(Math.floor((newTime - safeTipData.oldTime)/1000) >data.interval && safeTipData.todayNum < data.showCountDay && safeTipData.num < data.showCountBrowse){
  153. // this.globalData.openTipsNum = 0;
  154. safeTipData.oldDate = newDate;
  155. safeTipData.num = (safeTipData.num ? safeTipData.num : 0) + 1;
  156. safeTipData.todayNum = safeTipData.todayNum + 1;
  157. safeTipData.oldTime = newTime;
  158. safeTipData.show = true;
  159. this.setData({ isShow : safeTipData.show });
  160. }else {
  161. safeTipData.show = false;
  162. this.setData({ isShow : safeTipData.show });
  163. }
  164. }
  165. wx.setStorageSync("safeTips", safeTipData);
  166. } else {
  167. if (wx.getStorageSync("safeTips").modalId) {
  168. wx.removeStorageSync('safeTips')
  169. }
  170. this.defaultTips();
  171. }
  172. },
  173. defaultTips(){
  174. let newDate = util.getNowFormatDate('yyyy-MM-dd'), data = wx.getStorageSync("safeTips") || {},newHours = new Date().getHours();
  175. if (util.isObjEmpty(data) || (util.datedifference(newDate, data.oldDate) > 0 && data.num < 9999)) {
  176. // this.globalData.openTipsNum = 0;
  177. data.oldDate = newDate;
  178. data.num = (data.num ? data.num : 0) + 1;
  179. data.todayNum = 1;
  180. data.oldHours = newHours;
  181. data.show = true;
  182. this.setData({
  183. isShow:true
  184. })
  185. } else if((newHours - data.oldHours) >2 && data.todayNum < 2 && data.num < 9999){
  186. // this.globalData.openTipsNum = 0;
  187. data.oldDate = newDate;
  188. data.num = (data.num ? data.num : 0) + 1;
  189. data.todayNum = 2;
  190. data.oldHours = newHours;
  191. data.show = true;
  192. this.setData({
  193. isShow:true
  194. })
  195. }else{
  196. data.show = false;
  197. this.setData({
  198. isShow:false
  199. })
  200. }
  201. wx.setStorageSync("safeTips", data);
  202. },
  203. }
  204. });