index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.setBarColor();
  32. app.setUserInfo();
  33. if (options.id){
  34. this.setData({
  35. seckillId: options.id
  36. })
  37. this.getSeckillDetail();
  38. }else{
  39. wx.showToast({
  40. title: '参数错误',
  41. icon: 'none',
  42. duration: 1000
  43. })
  44. setTimeout(function(){
  45. wx.navigateTo({
  46. url: '/pages/miao-list/miao-list?'
  47. })
  48. },1200)
  49. }
  50. this.getCartCount();
  51. },
  52. getCartCount: function () {
  53. var that = this;
  54. var header = {
  55. 'content-type': 'application/x-www-form-urlencoded',
  56. };
  57. wx.request({
  58. url: app.globalData.url + '/routine/auth_api/get_cart_num?uid=' + app.globalData.uid,
  59. method: 'POST',
  60. header: header,
  61. success: function (res) {
  62. that.setData({
  63. CartCount: res.data.data
  64. })
  65. }
  66. })
  67. },
  68. getCar: function () {
  69. wx.switchTab({
  70. url: '/pages/buycar/buycar'
  71. });
  72. },
  73. goCoupon: function () {
  74. wx.navigateTo({
  75. url: "/pages/coupon-status/coupon-status"
  76. })
  77. },
  78. getSeckillDetail:function(){
  79. var that = this;
  80. var header = {
  81. 'content-type': 'application/x-www-form-urlencoded',
  82. };
  83. wx.request({
  84. url: app.globalData.url + '/routine/auth_api/seckill_detail?uid=' + app.globalData.uid,
  85. method: 'POST',
  86. header: header,
  87. data:{
  88. id: that.data.seckillId
  89. },
  90. success: function (res) {
  91. console.log(res);
  92. that.setData({
  93. SeckillList: res.data.data.storeInfo,
  94. replyCount: res.data.data.replyCount,
  95. reply: res.data.data.reply
  96. });
  97. var timeStamp = that.data.SeckillList.stop_time;
  98. wxh.time(timeStamp, that);
  99. WxParse.wxParse('description', 'html', that.data.SeckillList.description, that, 0);
  100. }
  101. })
  102. },
  103. parameterShow: function (e) {
  104. var that = this;
  105. wx.request({
  106. url: app.globalData.url + '/routine/auth_api/get_form_id?uid=' + app.globalData.uid,
  107. method: 'GET',
  108. data: {
  109. formId: e.detail.formId
  110. },
  111. success: function (res) { }
  112. })
  113. wx.request({
  114. url: app.globalData.url + '/routine/auth_api/now_buy?uid=' + app.globalData.uid,
  115. method: 'GET',
  116. data: {
  117. productId: that.data.SeckillList.product_id,
  118. cartNum: that.data.num,
  119. uniqueId: '',
  120. combinationId:0,
  121. secKillId: that.data.seckillId
  122. },
  123. success: function (res) {
  124. if (res.data.code == 200) {
  125. wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候)
  126. url: '/pages/order-confirm/order-confirm?id=' + res.data.data.cartId
  127. })
  128. } else {
  129. wx.showToast({
  130. title: res.data.msg,
  131. icon: 'none',
  132. duration: 2000
  133. })
  134. }
  135. }
  136. })
  137. },
  138. modelbg: function (e) {
  139. this.setData({
  140. prostatus: false
  141. })
  142. },
  143. bindMinus: function () {
  144. var that = this;
  145. wxh.carmin(that)
  146. },
  147. bindPlus: function () {
  148. var that = this;
  149. wxh.carjia(that);
  150. },
  151. tapsize: function (e) {
  152. console.log("123");
  153. var that = this;
  154. wxh.tapsize(that, e);
  155. },
  156. tapcolor: function (e) {
  157. var that = this;
  158. wxh.tapcolor(that, e);
  159. },
  160. setCollect: function () {
  161. if (this.data.collect) this.unCollectProduct();
  162. else this.collectProduct();
  163. },
  164. unCollectProduct: function () {
  165. var that = this;
  166. var header = {
  167. 'content-type': 'application/x-www-form-urlencoded',
  168. };
  169. wx.request({
  170. url: app.globalData.url + '/routine/auth_api/uncollect_product?uid=' + app.globalData.uid,
  171. method: 'POST',
  172. header: header,
  173. data: {
  174. productId: that.data.SeckillList.product_id,
  175. category: 'product_seckill'
  176. },
  177. success: function (res) {
  178. that.setData({
  179. collect: false,
  180. })
  181. }
  182. })
  183. },
  184. collectProduct: function () {
  185. var that = this;
  186. var header = {
  187. 'content-type': 'application/x-www-form-urlencoded',
  188. };
  189. wx.request({
  190. url: app.globalData.url + '/routine/auth_api/collect_product?uid=' + app.globalData.uid,
  191. method: 'POST',
  192. header: header,
  193. data: {
  194. productId: that.data.SeckillList.product_id,
  195. category:'product_seckill'
  196. },
  197. success: function (res) {
  198. that.setData({
  199. collect: true,
  200. })
  201. }
  202. })
  203. },
  204. /**
  205. * 生命周期函数--监听页面初次渲染完成
  206. */
  207. onReady: function () {
  208. },
  209. /**
  210. * 生命周期函数--监听页面显示
  211. */
  212. onShow: function () {
  213. },
  214. /**
  215. * 生命周期函数--监听页面隐藏
  216. */
  217. onHide: function () {
  218. },
  219. /**
  220. * 生命周期函数--监听页面卸载
  221. */
  222. onUnload: function () {
  223. },
  224. /**
  225. * 页面相关事件处理函数--监听用户下拉动作
  226. */
  227. onPullDownRefresh: function () {
  228. },
  229. /**
  230. * 页面上拉触底事件的处理函数
  231. */
  232. onReachBottom: function () {
  233. },
  234. /**
  235. * 用户点击右上角分享
  236. */
  237. onShareAppMessage: function () {
  238. }
  239. })