index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. var interval = 0,
  2. page_first_init = !0,
  3. timer = 1,
  4. fullScreen = !1,
  5. page_first = [];
  6. Page({
  7. data: {
  8. WindowWidth: getApp().core.getSystemInfoSync().windowWidth,
  9. WindowHeight: getApp().core.getSystemInfoSync().windowHeight,
  10. left: 0,
  11. show_notice: -1,
  12. animationData: {},
  13. play: -1,
  14. time: 0,
  15. buy: !1,
  16. opendate: !1,
  17. goods: "",
  18. form: {
  19. number: 1
  20. },
  21. time_all: []
  22. },
  23. onLoad: function(t) {
  24. getApp().page.onLoad(this, t), t.page_id || (t.page_id = -1), this.setData({
  25. options: t
  26. }), this.loadData(t)
  27. if(t.go&&t.go=='nd'){
  28. this.setData({
  29. user_info_show:false
  30. })
  31. }
  32. },
  33. suspension: function() {
  34. var o = this;
  35. interval = setInterval(function() {
  36. getApp().request({
  37. url: getApp().api.default.buy_data,
  38. data: {
  39. time: o.data.time
  40. },
  41. method: "POST",
  42. success: function(t) {
  43. if (0 == t.code) {
  44. var a = !1;
  45. o.data.msgHistory == t.md5 && (a = !0);
  46. var e = "",
  47. i = t.cha_time,
  48. s = Math.floor(i / 60 - 60 * Math.floor(i / 3600));
  49. e = 0 == s ? i % 60 + "秒" : s + "分" + i % 60 + "秒", !a && t.cha_time <= 300 ? o.setData({
  50. buy: {
  51. time: e,
  52. type: t.data.type,
  53. url: t.data.url,
  54. user: 5 <= t.data.user.length ? t.data.user.slice(0, 4) + "..." : t.data.user,
  55. avatar_url: t.data.avatar_url,
  56. address: 8 <= t.data.address.length ? t.data.address.slice(0, 7) + "..." : t.data.address,
  57. content: t.data.content
  58. },
  59. msgHistory: t.md5
  60. }) : o.setData({
  61. buy: !1
  62. })
  63. }
  64. },
  65. noHandlerFail: !0
  66. })
  67. }, 1e4)
  68. },
  69. dis: function () {
  70. this.setData({
  71. user_info_show: false
  72. })
  73. },
  74. loadData: function() {
  75. var i = this,
  76. t = {},
  77. s = i.data.options;
  78. if (-1 != s.page_id) t.page_id = s.page_id;
  79. else {
  80. t.page_id = -1;
  81. var a = getApp().core.getStorageSync(getApp().const.PAGE_INDEX_INDEX);
  82. a && (a.act_modal_list = [], i.setData(a))
  83. }
  84. getApp().request({
  85. url: getApp().api.default.index,
  86. data: t,
  87. success: function(t) {
  88. if (0 == t.code) {
  89. if ("diy" == t.data.status) {
  90. var a = t.data.act_modal_list; - 1 != s.page_id && (getApp().core.setNavigationBarTitle({
  91. title: t.data.info
  92. }), i.setData({
  93. title: t.data.info
  94. }));
  95. for (var e = a.length - 1; 0 <= e; e--)(void 0 === a[e].status || 0 == a[e].status) && getApp().helper.inArray(a[e].page_id, page_first) && !i.data.user_info_show || 0 == a[e].show ? a.splice(e, 1) : page_first.push(a[e].page_id);
  96. i.setData({
  97. template: t.data.template,
  98. act_modal_list: a,
  99. time_all: t.data.time_all
  100. }), i.setTime()
  101. } else page_first_init ? i.data.user_info_show || (page_first_init = !1) : t.data.act_modal_list = [], i.setData(t.data), i.miaoshaTimer(); - 1 == s.page_id && getApp().core.setStorageSync(getApp().const.PAGE_INDEX_INDEX, t.data)
  102. }
  103. },
  104. complete: function() {
  105. getApp().core.stopPullDownRefresh()
  106. }
  107. })
  108. },
  109. onShow: function() {
  110. var e = this;
  111. getApp().page.onShow(this), require("./../../components/diy/diy.js").init(this), getApp().getConfig(function(t) {
  112. var a = t.store;
  113. a && a.name && -1 == e.data.options.page_id && getApp().core.setNavigationBarTitle({
  114. title: a.name
  115. }), a && 1 === a.purchase_frame ? e.suspension(e.data.time) : e.setData({
  116. buy_user: ""
  117. })
  118. }), getApp().query = null
  119. },
  120. onPullDownRefresh: function() {
  121. getApp().getStoreData(), clearInterval(timer), this.loadData()
  122. },
  123. onShareAppMessage: function(t) {
  124. getApp().page.onShareAppMessage(this);
  125. var a = this,
  126. e = getApp().getUser();
  127. return -1 != a.data.options.page_id ? {
  128. path: "/pages/index/index?user_id=" + e.id + "&page_id=" + a.data.options.page_id,
  129. title: a.data.title
  130. } : {
  131. path: "/pages/index/index?user_id=" + e.id,
  132. title: a.data.store.name
  133. }
  134. },
  135. showshop: function(t) {
  136. var a = this,
  137. e = t.currentTarget.dataset.id,
  138. i = t.currentTarget.dataset;
  139. getApp().request({
  140. url: getApp().api.default.goods,
  141. data: {
  142. id: e
  143. },
  144. success: function(t) {
  145. 0 == t.code && a.setData({
  146. data: i,
  147. attr_group_list: t.data.attr_group_list,
  148. goods: t.data,
  149. showModal: !0
  150. })
  151. }
  152. })
  153. },
  154. miaoshaTimer: function() {
  155. var t = this;
  156. t.data.miaosha && 0 != t.data.miaosha.rest_time && (t.data.miaosha.ms_next || (timer = setInterval(function() {
  157. 0 < t.data.miaosha.rest_time ? (t.data.miaosha.rest_time = t.data.miaosha.rest_time - 1, t.data.miaosha.times = t.setTimeList(t.data.miaosha.rest_time), t.setData({
  158. miaosha: t.data.miaosha
  159. })) : clearInterval(timer)
  160. }, 1e3)))
  161. },
  162. onHide: function() {
  163. getApp().page.onHide(this), this.setData({
  164. play: -1
  165. }), clearInterval(interval)
  166. },
  167. onUnload: function() {
  168. getApp().page.onUnload(this), this.setData({
  169. play: -1
  170. }), clearInterval(timer), clearInterval(interval)
  171. },
  172. showNotice: function(t) {
  173. console.log(t), this.setData({
  174. show_notice: t.currentTarget.dataset.index
  175. })
  176. },
  177. closeNotice: function() {
  178. this.setData({
  179. show_notice: -1
  180. })
  181. },
  182. to_dial: function() {
  183. var t = this.data.store.contact_tel;
  184. getApp().core.makePhoneCall({
  185. phoneNumber: t
  186. })
  187. },
  188. closeActModal: function() {
  189. var a = this,
  190. e = a.data.act_modal_list;
  191. for (var t in e) {
  192. var i = parseInt(t);
  193. e[i].show && (e[i].show = !1);
  194. break
  195. }
  196. a.setData({
  197. act_modal_list: e
  198. }), setTimeout(function() {
  199. for (var t in e)
  200. if (e[t].show) {
  201. e = e.splice(t, 1).concat(e);
  202. break
  203. }
  204. a.setData({
  205. act_modal_list: e
  206. })
  207. }, 500)
  208. },
  209. naveClick: function(t) {
  210. getApp().navigatorClick(t, this)
  211. },
  212. onPageScroll: function(t) {
  213. var a = this;
  214. if (!fullScreen && -1 != a.data.play) {
  215. var e = getApp().core.getSystemInfoSync().windowHeight;
  216. "undefined" == typeof my ? getApp().core.createSelectorQuery().select(".video").fields({
  217. rect: !0
  218. }, function(t) {
  219. (t.top <= -200 || t.top >= e - 57) && a.setData({
  220. play: -1
  221. })
  222. }).exec() : getApp().core.createSelectorQuery().select(".video").boundingClientRect().scrollOffset().exec(function(t) {
  223. (t[0].top <= -200 || t[0].top >= e - 57) && a.setData({
  224. play: -1
  225. })
  226. })
  227. }
  228. },
  229. fullscreenchange: function(t) {
  230. fullScreen = !!t.detail.fullScreen
  231. },
  232. shuoming: function () {
  233. getApp().core.navigateTo({
  234. url: "/pages/integral-mall/shuoming/index"
  235. })
  236. },
  237. exchange: function () {
  238. getApp().core.navigateTo({
  239. url: "/pages/integral-mall/exchange/index"
  240. })
  241. },
  242. detail: function () {
  243. getApp().core.navigateTo({
  244. url: "/pages/integral-mall/detail/index"
  245. })
  246. },
  247. register: function () {
  248. getApp().core.navigateTo({
  249. url: "/pages/integral-mall/register/index"
  250. })
  251. }
  252. });