index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 ? {channalPwd: this.data.Value}: false
  67. this.getMadeList(this,data); // 获取商品列表
  68. this.getCarlist(this);//获取购物车列表
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. },
  95. customized(e){
  96. if (e.currentTarget.dataset.state == '1'){
  97. return;
  98. }
  99. console.log('canvas')
  100. let user_id = getApp().globalData.user_id;
  101. console.log(user_id, "user_iduser_iduser_id")
  102. if (!user_id) {
  103. wx.navigateTo({
  104. url: '/pages/authorize/authorize?link=customized',
  105. })
  106. } else {
  107. wx.navigateTo({
  108. url: "/customized/pages/made/made",
  109. })
  110. }
  111. },
  112. getCarlist(that) {
  113. wx.request({
  114. url: host + '/queryShopCar',
  115. method: 'post',
  116. header: {
  117. 'content-type': 'application/x-www-form-urlencoded'
  118. },
  119. data: {
  120. userId: app.globalData.user_id //app.globalData.user_id //'oovpNwjlsY6xx8ceCebFa1dOLd9E' //app.globalData.user_id,
  121. },
  122. success: function (res) {
  123. console.log('购物车列表数据', res)
  124. that.setData({
  125. carNum: res.data.length
  126. })
  127. }
  128. })
  129. },
  130. getMadeList(that,data){ // 获取列表
  131. wx.showLoading({
  132. title: '加载中...',
  133. })
  134. wx.request({
  135. url: host+ '/custom/queryNotOpenCustomGoodsByPwd',
  136. method:'get',
  137. header: {
  138. 'content-type': 'application/x-www-form-urlencoded'
  139. },
  140. data:data? data:{},
  141. success(res){
  142. console.log(res)
  143. if(res.data.length === 0 && data){
  144. wx.showToast({
  145. title: '密码输入错误',
  146. icon:'none'
  147. })
  148. } else {
  149. that.setData({
  150. madeList: [...res.data]
  151. })
  152. }
  153. },
  154. fail(err){
  155. console.log(err)
  156. },
  157. complete(){
  158. console.log('完成');
  159. wx.hideLoading()
  160. }
  161. })
  162. },
  163. vipBtn(){ // 表示是vip操作
  164. this.setData({
  165. pwdStatic:true
  166. })
  167. },
  168. Focus(e) {
  169. var that = this;
  170. console.log(e.detail.value);
  171. var inputValue = e.detail.value;
  172. that.setData({
  173. Value: inputValue,
  174. })
  175. },
  176. Tap() {
  177. var that = this;
  178. that.setData({
  179. isFocus: true,
  180. })
  181. },
  182. fromDel(){
  183. this.setData({
  184. Value: "",
  185. })
  186. },
  187. formSubmit(e) {
  188. console.log(this.data.Value);
  189. this.getMadeList(this,{
  190. channalPwd: this.data.Value
  191. })
  192. },
  193. close(){
  194. this.setData({
  195. pwdStatic:false
  196. })
  197. }
  198. })