C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

217 rindas
4.0 KiB

  1. var app = getApp();
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  3. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  4. const Http = require("../../utils/HttpBasics");
  5. const config = require("../../config/config.js");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. navigationBarHeight,
  12. num:1,
  13. showShade:false,
  14. coverImg:"",
  15. title:"",
  16. salePriceStr:"",//单价
  17. freightPriceStr:"",//运费
  18. remainInventory: "",//库存
  19. seti:[],
  20. area:"",
  21. address:"",
  22. consignee:"",
  23. mobile:"",
  24. },
  25. goAddStie(){
  26. wx.navigateTo({
  27. url: '/pages/siteAdd/siteAdd?url=/pages/fillIndent/fillIndent',
  28. })
  29. },
  30. setSite(e){
  31. let id = e.currentTarget.dataset.id
  32. let arr = []
  33. arr = this.data.seti.filter(item=>{
  34. return item.id == id
  35. })[0]
  36. console.log(arr)
  37. this.setData({
  38. area: arr.regionStr,
  39. address: arr.address,
  40. consignee: arr.consignee,
  41. mobile: arr.mobile,
  42. })
  43. },
  44. getSetiLsit(){
  45. Http.get({
  46. url: config.api.siteList,
  47. data:{
  48. pageNum: 1,
  49. pageSize: 1000
  50. }
  51. }).then(res=>{
  52. let temp = res.data.list
  53. if(temp.length>0){
  54. temp.map(item => {
  55. // let regionStr = ""
  56. let tempstr = ""
  57. JSON.parse(item.region).map(item2 => {
  58. tempstr += item2
  59. })
  60. item.regionStr = tempstr
  61. })
  62. console.log(temp, "temp")
  63. this.setData({
  64. seti: temp,
  65. })
  66. let tempRegion = JSON.parse(temp[0].region)
  67. let str = ""
  68. tempRegion.map(item => { str += item })
  69. this.setData({
  70. area: str,
  71. address: temp[0].address,
  72. consignee: temp[0].consignee,
  73. mobile: temp[0].mobile
  74. })
  75. }
  76. }).catch(err => {
  77. wx.showToast({
  78. title: err.message ? err.message : err.data,
  79. icon: 'none',
  80. duration: 2000,
  81. });
  82. })
  83. },
  84. addNum(){
  85. let num = this.data.num
  86. if (this.data.num >= this.data.remainInventory){
  87. wx.showToast({
  88. title: '购买总数超库存',
  89. icon: 'none',
  90. duration: 2000,
  91. })
  92. }else{
  93. num = num + 1
  94. this.setData({
  95. num: num
  96. })
  97. }
  98. },
  99. dleNum(){
  100. let num = this.data.num
  101. if (this.data.num <=1){
  102. wx.showToast({
  103. title: '购买总数不能为0',
  104. icon: 'none',
  105. duration: 2000,
  106. })
  107. }else{
  108. num = num - 1
  109. this.setData({
  110. num: num
  111. })
  112. }
  113. },
  114. hieShade(){
  115. this.setData({
  116. showShade:false
  117. })
  118. },
  119. showTShade(){
  120. this.setData({
  121. showShade: true
  122. })
  123. },
  124. /**
  125. * 生命周期函数--监听页面加载
  126. */
  127. onLoad: function (options) {
  128. this.setData({
  129. id:options.id
  130. })
  131. this.getCouponDetail()
  132. this.getSetiLsit()
  133. },
  134. getCouponDetail(){
  135. Http.get({
  136. url: config.api.couponDetail,
  137. data:{
  138. couponChannelId:this.data.id
  139. }
  140. }).then(res=>{
  141. let temp = res.data
  142. this.setData({
  143. coverImg: temp.coverImg,
  144. title: temp.title,
  145. salePriceStr: temp.salePriceStr,
  146. freightPriceStr: temp.freightPriceStr,
  147. remainInventory: temp.remainInventory
  148. })
  149. }).catch(err=>{
  150. wx.showToast({
  151. title: err.message ? err.message : err.data,
  152. icon: 'none',
  153. duration: 2000,
  154. });
  155. })
  156. },
  157. /**
  158. * 生命周期函数--监听页面初次渲染完成
  159. */
  160. onReady: function () {
  161. },
  162. /**
  163. * 生命周期函数--监听页面显示
  164. */
  165. onShow: function () {
  166. },
  167. /**
  168. * 生命周期函数--监听页面隐藏
  169. */
  170. onHide: function () {
  171. },
  172. /**
  173. * 生命周期函数--监听页面卸载
  174. */
  175. onUnload: function () {
  176. },
  177. /**
  178. * 页面相关事件处理函数--监听用户下拉动作
  179. */
  180. onPullDownRefresh: function () {
  181. },
  182. /**
  183. * 页面上拉触底事件的处理函数
  184. */
  185. onReachBottom: function () {
  186. },
  187. /**
  188. * 用户点击右上角分享
  189. */
  190. onShareAppMessage: function () {
  191. }
  192. })