index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. Value: "", //输入的内容
  12. ispassword: true, //是否密文显示 true为密文, false为明文。
  13. pwdStatic: false, // 密码状态框,是否显示
  14. carNum: null,
  15. host: host,
  16. keyboard:[[1,2,3],[4,5,6],[7,8,9]],
  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&url="/customized/pages/goodsDetail/goodsDetail"',
  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. Tap() {
  172. var that = this;
  173. that.setData({
  174. isFocus: true,
  175. })
  176. },
  177. close() {
  178. this.setData({
  179. pwdStatic: false,
  180. Value:""
  181. })
  182. },
  183. keyboard(e){
  184. let num = e.currentTarget.dataset.num,
  185. that = this,
  186. Value = that.data.Value;
  187. console.log(that.data.Value.length,"长度")
  188. if (Value.length < 6){
  189. Value += num;
  190. }
  191. that.setData({
  192. Value: Value,
  193. })
  194. if (that.data.Value.length >= 6){
  195. that.close();
  196. setTimeout(()=>{
  197. that.getMadeList(that, {
  198. channalPwd: Value
  199. })
  200. },200)
  201. }
  202. console.log(that.data.Value)
  203. },
  204. keyboardDel(){
  205. let that = this;
  206. that.setData({
  207. Value: that.data.Value.substring(0, that.data.Value.length-1)
  208. })
  209. console.log(that.data.Value)
  210. }
  211. })