index.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. // pages/product-con/index.js
  2. var app = getApp();
  3. var wxh = require('../../utils/wxh.js');
  4. var WxParse = require('../../wxParse/wxParse.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. url: app.globalData.urlImages,
  11. indicatorDots: true,//是否显示面板指示点;
  12. autoplay: true,//是否自动播放;
  13. interval: 3000,//动画间隔的时间;
  14. duration: 500,//动画播放的时长;
  15. indicatorColor: "rgba(51, 51, 51, .3)",
  16. indicatorActivecolor: "#ffffff",
  17. countDownHour: "00",
  18. countDownMinute: "00",
  19. countDownSecond: "00",
  20. reply:[],
  21. replyCount:0,
  22. collect:false,
  23. SeckillList:[],
  24. CartCount: 0,
  25. seckillId:0
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. app.globalData.openPages = '/pages/product-countdown/index?id=' + options.id + '&scene=' + app.globalData.uid;
  32. app.setBarColor();
  33. app.setUserInfo();
  34. if (options.id){
  35. this.setData({
  36. seckillId: options.id
  37. })
  38. this.getSeckillDetail();
  39. }else{
  40. wx.showToast({
  41. title: '参数错误',
  42. icon: 'none',
  43. duration: 1000
  44. })
  45. setTimeout(function(){
  46. wx.navigateTo({
  47. url: '/pages/miao-list/miao-list?'
  48. })
  49. },1200)
  50. }
  51. this.getCartCount();
  52. },
  53. getCartCount: function () {
  54. var that = this;
  55. var header = {
  56. 'content-type': 'application/x-www-form-urlencoded',
  57. };
  58. wx.request({
  59. url: app.globalData.url + '/routine/auth_api/get_cart_num?uid=' + app.globalData.uid,
  60. method: 'POST',
  61. header: header,
  62. success: function (res) {
  63. that.setData({
  64. CartCount: res.data.data
  65. })
  66. }
  67. })
  68. },
  69. getCar: function () {
  70. wx.switchTab({
  71. url: '/pages/buycar/buycar'
  72. });
  73. },
  74. goCoupon: function () {
  75. wx.navigateTo({
  76. url: "/pages/coupon-status/coupon-status"
  77. })
  78. },
  79. getSeckillDetail:function(){
  80. var that = this;
  81. var header = {
  82. 'content-type': 'application/x-www-form-urlencoded',
  83. };
  84. wx.request({
  85. url: app.globalData.url + '/routine/auth_api/seckill_detail?uid=' + app.globalData.uid,
  86. method: 'POST',
  87. header: header,
  88. data:{
  89. id: that.data.seckillId
  90. },
  91. success: function (res) {
  92. if(res.data.code == 200){
  93. that.setData({
  94. SeckillList: res.data.data.storeInfo,
  95. replyCount: res.data.data.replyCount,
  96. reply: res.data.data.reply
  97. });
  98. var timeStamp = that.data.SeckillList.stop_time;
  99. wxh.time(timeStamp, that);
  100. WxParse.wxParse('description', 'html', that.data.SeckillList.description, that, 0);
  101. }else{
  102. if (app.globalData.uid == null) {//是否存在用户信息,如果不存在跳转到首页
  103. setTimeout(function () { wx.navigateTo({ url: '/pages/loading/loading' }) }, 1500)
  104. } else {
  105. wx.showToast({
  106. title: res.data.msg,
  107. icon: 'none',
  108. duration: 1000
  109. });
  110. setTimeout(function () { wx.navigateBack({}); }, 1200);
  111. }
  112. }
  113. }
  114. })
  115. },
  116. parameterShow: function (e) {
  117. var that = this;
  118. wx.request({
  119. url: app.globalData.url + '/routine/auth_api/get_form_id?uid=' + app.globalData.uid,
  120. method: 'GET',
  121. data: {
  122. formId: e.detail.formId
  123. },
  124. success: function (res) { }
  125. })
  126. wx.request({
  127. url: app.globalData.url + '/routine/auth_api/now_buy?uid=' + app.globalData.uid,
  128. method: 'GET',
  129. data: {
  130. productId: that.data.SeckillList.product_id,
  131. cartNum: that.data.num,
  132. uniqueId: '',
  133. combinationId:0,
  134. secKillId: that.data.seckillId
  135. },
  136. success: function (res) {
  137. if (res.data.code == 200) {
  138. wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
  139. url: '/pages/order-confirm/order-confirm?id=' + res.data.data.cartId
  140. })
  141. } else {
  142. wx.showToast({
  143. title: res.data.msg,
  144. icon: 'none',
  145. duration: 2000
  146. })
  147. }
  148. }
  149. })
  150. },
  151. modelbg: function (e) {
  152. this.setData({
  153. prostatus: false
  154. })
  155. },
  156. bindMinus: function () {
  157. var that = this;
  158. wxh.carmin(that)
  159. },
  160. bindPlus: function () {
  161. var that = this;
  162. wxh.carjia(that);
  163. },
  164. tapsize: function (e) {
  165. console.log("123");
  166. var that = this;
  167. wxh.tapsize(that, e);
  168. },
  169. tapcolor: function (e) {
  170. var that = this;
  171. wxh.tapcolor(that, e);
  172. },
  173. setCollect: function () {
  174. if (this.data.collect) this.unCollectProduct();
  175. else this.collectProduct();
  176. },
  177. unCollectProduct: function () {
  178. var that = this;
  179. var header = {
  180. 'content-type': 'application/x-www-form-urlencoded',
  181. };
  182. wx.request({
  183. url: app.globalData.url + '/routine/auth_api/uncollect_product?uid=' + app.globalData.uid,
  184. method: 'POST',
  185. header: header,
  186. data: {
  187. productId: that.data.SeckillList.product_id,
  188. category: 'product_seckill'
  189. },
  190. success: function (res) {
  191. that.setData({
  192. collect: false,
  193. })
  194. }
  195. })
  196. },
  197. collectProduct: function () {
  198. var that = this;
  199. var header = {
  200. 'content-type': 'application/x-www-form-urlencoded',
  201. };
  202. wx.request({
  203. url: app.globalData.url + '/routine/auth_api/collect_product?uid=' + app.globalData.uid,
  204. method: 'POST',
  205. header: header,
  206. data: {
  207. productId: that.data.SeckillList.product_id,
  208. category:'product_seckill'
  209. },
  210. success: function (res) {
  211. that.setData({
  212. collect: true,
  213. })
  214. }
  215. })
  216. },
  217. /**
  218. * 生命周期函数--监听页面初次渲染完成
  219. */
  220. onReady: function () {
  221. },
  222. /**
  223. * 生命周期函数--监听页面显示
  224. */
  225. onShow: function () {
  226. },
  227. /**
  228. * 生命周期函数--监听页面隐藏
  229. */
  230. onHide: function () {
  231. },
  232. /**
  233. * 生命周期函数--监听页面卸载
  234. */
  235. onUnload: function () {
  236. },
  237. /**
  238. * 页面相关事件处理函数--监听用户下拉动作
  239. */
  240. onPullDownRefresh: function () {
  241. },
  242. /**
  243. * 页面上拉触底事件的处理函数
  244. */
  245. onReachBottom: function () {
  246. },
  247. /**
  248. * 用户点击右上角分享
  249. */
  250. onShareAppMessage: function () {
  251. return {
  252. title: that.data.productSelect.store_name,
  253. path: app.globalData.openPages,
  254. // imageUrl: that.data.url + that.data.product.image,
  255. success: function () {
  256. wx.showToast({
  257. title: '分享成功',
  258. icon: 'success',
  259. duration: 2000
  260. })
  261. }
  262. }
  263. }
  264. })