index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // pages/customized/index/index.js
  2. // customized/pages/made/car/car.js
  3. let app = getApp();
  4. let host = app.globalData.servsers; // 请求的url
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. Length: 6, //输入框个数
  11. isFocus: true, //聚焦
  12. Value: "", //输入的内容
  13. ispassword: true, //是否密文显示 true为密文, false为明文。
  14. pwdStatic: false, // 密码状态框,是否显示
  15. carNum: null,
  16. host: host,
  17. madeList: [
  18. // {
  19. // src:'/customized/images/customized/cup_black_small.png',
  20. // name:'奶缸-黑色 350ml',
  21. // price:'¥45.00',
  22. // btnText:'去定制',
  23. // btnDisabled:false,
  24. // state:true,
  25. // },
  26. // {
  27. // src: '/customized/images/customized/cup_black_small_2.png',
  28. // name: '奶缸-白色 350ml',
  29. // price: '¥45.00',
  30. // btnText: '去定制',
  31. // btnDisabled: true,
  32. // state: false,
  33. // },
  34. // {
  35. // src: '/customized/images/customized/cup_black_small_3.png',
  36. // name: '马克杯-白色 450ml',
  37. // price: '¥45.00',
  38. // btnText: '去定制',
  39. // btnDisabled: true,
  40. // state: false,
  41. // },
  42. // {
  43. // src: '/customized/images/customized/cup_black_small_4.png',
  44. // name: '马克杯-白色 300ml',
  45. // price: '¥45.00',
  46. // btnText: '去定制',
  47. // btnDisabled: true,
  48. // state: false,
  49. // }
  50. ]
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad: function (options) {
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function () {
  66. let data = this.data.Value ? {
  67. channalPwd: this.data.Value
  68. } : false
  69. this.getMadeList(this, data); // 获取商品列表
  70. this.getCarlist(this); //获取购物车列表
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh: function () {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage: function () {
  96. },
  97. customized(e) {
  98. if (e.currentTarget.dataset.state == '1') {
  99. return;
  100. }
  101. console.log('canvas')
  102. let user_id = getApp().globalData.user_id;
  103. console.log(user_id, "user_iduser_iduser_id")
  104. if (!user_id) {
  105. wx.navigateTo({
  106. url: '/pages/authorize/authorize?link=customized',
  107. })
  108. } else {
  109. wx.setStorageSync('detail', e.currentTarget.dataset.detail)
  110. wx.navigateTo({
  111. url: "/customized/pages/goodsDetail/goodsDetail",
  112. })
  113. }
  114. },
  115. getCarlist(that) {
  116. wx.request({
  117. url: host + '/queryShopCar',
  118. method: 'post',
  119. header: {
  120. 'content-type': 'application/x-www-form-urlencoded'
  121. },
  122. data: {
  123. userId: app.globalData.user_id //app.globalData.user_id //'oovpNwjlsY6xx8ceCebFa1dOLd9E' //app.globalData.user_id,
  124. },
  125. success: function (res) {
  126. console.log('购物车列表数据', res)
  127. that.setData({
  128. carNum: res.data.length
  129. })
  130. }
  131. })
  132. },
  133. getMadeList(that, data) { // 获取列表
  134. wx.showLoading({
  135. title: '加载中...',
  136. })
  137. wx.request({
  138. url: host + '/custom/queryNotOpenCustomGoodsByPwd',
  139. method: 'get',
  140. header: {
  141. 'content-type': 'application/x-www-form-urlencoded'
  142. },
  143. data: data ? data : {},
  144. success(res) {
  145. console.log(res)
  146. if (res.data.length === 0 && data) {
  147. wx.showToast({
  148. title: '密码输入错误',
  149. icon: 'none'
  150. })
  151. } else {
  152. that.setData({
  153. madeList: [...res.data]
  154. })
  155. }
  156. },
  157. fail(err) {
  158. console.log(err)
  159. },
  160. complete() {
  161. console.log('完成');
  162. wx.hideLoading()
  163. }
  164. })
  165. },
  166. vipBtn() { // 表示是vip操作
  167. this.setData({
  168. pwdStatic: true
  169. })
  170. },
  171. Focus(e) {
  172. var that = this;
  173. console.log(e.detail.value);
  174. var inputValue = e.detail.value;
  175. that.setData({
  176. Value: inputValue,
  177. })
  178. },
  179. Tap() {
  180. var that = this;
  181. that.setData({
  182. isFocus: true,
  183. })
  184. },
  185. fromDel() {
  186. this.setData({
  187. Value: "",
  188. })
  189. },
  190. formSubmit(e) {
  191. console.log(this.data.Value);
  192. this.getMadeList(this, {
  193. channalPwd: this.data.Value
  194. })
  195. },
  196. close() {
  197. this.setData({
  198. pwdStatic: false
  199. })
  200. }
  201. })