detail.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. // pages/my/postJob/detail.js
  2. var app = getApp();
  3. var util = require("../../utils/util.js")
  4. let wxparse = require("../../wxParse/wxParse.js");
  5. let pageid = ""
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. bottomLeft: app.bottomLeft,
  12. appAssetsUrl: app.appAssetsUrl,
  13. vipid: util.getUserId(),
  14. detail: {},
  15. workContent: '',
  16. vipMsg: '',
  17. arrayPrice: [],
  18. heightList: [],
  19. priceUnit: null,
  20. heightUnit: null,
  21. sex: null
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. this.setData({
  28. detail: wx.getStorageSync('workDetail'),
  29. user: wx.getStorageSync('USER')
  30. })
  31. // this.ready()
  32. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady: function () {
  37. //获得popup组件
  38. this.popup = this.selectComponent("#popup0");
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  44. this.getUnit()
  45. this.getHeightList()
  46. this.sex()
  47. },
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide: function () {},
  52. /**
  53. * 页面相关事件处理函数--监听用户下拉动作
  54. */
  55. onPullDownRefresh: function () {
  56. },
  57. /**
  58. * 页面上拉触底事件的处理函数
  59. */
  60. onReachBottom: function () {
  61. },
  62. showShareMenu: function () {},
  63. /**
  64. * 用户点击右上角分享
  65. */
  66. onShareAppMessage() {},
  67. // 预览图片
  68. previewImage(e) {
  69. wx.previewImage({
  70. urls: e.currentTarget.dataset.images,
  71. current: e.currentTarget.dataset.images[e.currentTarget.dataset.index]
  72. })
  73. },
  74. getUnit() {
  75. app._post_form('bizlibrary/infoList/workUnit', '', {}, res => {
  76. if (res.code === 0) {
  77. let priceUnit
  78. for (let i = 0; i < res.dictList.length; i++) {
  79. if (res.dictList[i].itemcode == this.data.detail.unit) {
  80. priceUnit = res.dictList[i].itemname
  81. break
  82. }
  83. }
  84. this.setData({
  85. priceUnit: priceUnit,
  86. arrayPrice: res.dictList
  87. })
  88. }
  89. })
  90. },
  91. getHeightList() {
  92. app._post_form('bizlibrary/infoList/workHeightLimit', '', {}, res => {
  93. if (res.code === 0) {
  94. let heightUnit
  95. for (let i = 0; i < res.dictList.length; i++) {
  96. if (res.dictList[i].itemcode == this.data.detail.unit) {
  97. heightUnit = res.dictList[i].itemname
  98. break
  99. }
  100. }
  101. this.setData({
  102. heightUnit: heightUnit,
  103. heightList: res.dictList
  104. })
  105. }
  106. })
  107. },
  108. sex() {
  109. console.log(app.sexList, 111)
  110. let sex
  111. for (let i = 0; i < app.sexList.length; i++) {
  112. if (app.sexList[i].itemcode == this.data.detail.sexlimit) {
  113. sex = app.sexList[i].itemname
  114. break
  115. }
  116. }
  117. this.setData({
  118. sex: sex,
  119. })
  120. },
  121. submit() {
  122. app._post_form('work/saveWork', '', this.data.detail, res => {
  123. if (res.code === 0) {
  124. wx.showToast({
  125. title: '添加成功',
  126. })
  127. wx.removeStorageSync('workDetail')
  128. wx.switchTab({
  129. url: '/pages/home/index/index',
  130. })
  131. }
  132. }, err => {}, complete => {
  133. setTimeout(() => {
  134. wx.hideLoading()
  135. }, 300)
  136. })
  137. },
  138. // 查看二维码
  139. seeCode() {
  140. this.popup.showPopup();
  141. },
  142. // 查看地图
  143. goLocal() {
  144. let that = this
  145. let [latitude, longitude] = [this.data.detail.coordinate.split(',')[0], this.data.detail.coordinate.split(',')[1]]
  146. console.log(Number(latitude), Number(longitude))
  147. wx.openLocation({
  148. latitude: Number(longitude),
  149. longitude: Number(latitude),
  150. name: that.data.detail.title,
  151. address: that.data.detail.address,
  152. success: function () {
  153. console.log("success");
  154. },
  155. });
  156. },
  157. // 会员必读
  158. ready() {
  159. let _this = this;
  160. app._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json',
  161. null,
  162. function (res) {
  163. if (res.code === 0) {
  164. // _this.setData({
  165. // vipMsg: res.wgFillInfo.vipMessage
  166. // })
  167. wxparse.wxParse('vipMsg', 'html', res.wgFillInfo.vipMessage, _this, 0);
  168. }
  169. }
  170. )
  171. },
  172. //取消事件
  173. _error(e) {
  174. this.popup.hidePopup();
  175. },
  176. //确认事件
  177. _success(e) {
  178. this.popup.hidePopup();
  179. },
  180. onUnload: function () {
  181. clearInterval(this.data.timer)
  182. }
  183. })