detail.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. appAssetsUrl2: app.appAssetsUrl2,
  14. vipid: util.getUserId(),
  15. detail: {},
  16. workContent: "",
  17. vipMsg: "",
  18. arrayPrice: [],
  19. heightList: [],
  20. priceUnit: null,
  21. heightUnit: null,
  22. sex: null,
  23. cashMethodList: [],
  24. cashMethodName: null
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. this.setData({
  31. detail: wx.getStorageSync("workDetail"),
  32. user: wx.getStorageSync("USER"),
  33. });
  34. // this.ready()
  35. },
  36. /**
  37. * 生命周期函数--监听页面初次渲染完成
  38. */
  39. onReady: function () {
  40. //获得popup组件
  41. this.popup = this.selectComponent("#popup0");
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow: function () {
  47. this.getUnit();
  48. this.getHeightList();
  49. this.sex();
  50. this.getCashMethod();
  51. },
  52. /**
  53. * 生命周期函数--监听页面隐藏
  54. */
  55. onHide: function () {},
  56. /**
  57. * 页面相关事件处理函数--监听用户下拉动作
  58. */
  59. onPullDownRefresh: function () {},
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom: function () {},
  64. showShareMenu: function () {},
  65. /**
  66. * 用户点击右上角分享
  67. */
  68. onShareAppMessage() {},
  69. // 预览图片
  70. previewImage(e) {
  71. wx.previewImage({
  72. urls: e.currentTarget.dataset.images,
  73. current: e.currentTarget.dataset.images[e.currentTarget.dataset.index],
  74. });
  75. },
  76. getUnit() {
  77. app._post_form("bizlibrary/infoList/workUnit", "", {}, (res) => {
  78. if (res.code === 0) {
  79. let priceUnit;
  80. for (let i = 0; i < res.dictList.length; i++) {
  81. if (res.dictList[i].itemcode == this.data.detail.unit) {
  82. priceUnit = res.dictList[i].itemname;
  83. break;
  84. }
  85. }
  86. this.setData({
  87. priceUnit: priceUnit,
  88. arrayPrice: res.dictList,
  89. });
  90. }
  91. });
  92. },
  93. getHeightList() {
  94. app._post_form("bizlibrary/infoList/workHeightLimit", "", {}, (res) => {
  95. if (res.code === 0) {
  96. let heightUnit;
  97. for (let i = 0; i < res.dictList.length; i++) {
  98. if (res.dictList[i].itemcode == this.data.detail.heightlimit) {
  99. heightUnit = res.dictList[i].itemname;
  100. break;
  101. }
  102. }
  103. this.setData({
  104. heightUnit: heightUnit,
  105. heightList: res.dictList,
  106. });
  107. }
  108. });
  109. },
  110. sex() {
  111. console.log(app.sexList, 111);
  112. let sex;
  113. let arr = [{
  114. itemname: '仅限男生',
  115. itemcode: '01',
  116. },{
  117. itemname: '仅限女生',
  118. itemcode: '02',
  119. },{
  120. itemname: '男女不限',
  121. itemcode: '03',
  122. }]
  123. for (let i = 0; i < arr.length; i++) {
  124. if (arr[i].itemcode == this.data.detail.sexlimit) {
  125. sex = arr[i].itemname;
  126. break;
  127. }
  128. }
  129. this.setData({
  130. sex: sex,
  131. });
  132. },
  133. // 获取结算方式
  134. getCashMethod() {
  135. app._post_form("work/cashMethod", "", {}, (res) => {
  136. if (res.code === 0) {
  137. let cashMethodName;
  138. for (let i = 0; i < res.data.length; i++) {
  139. if (res.data[i].itemcode == this.data.detail.cashMethod) {
  140. cashMethodName = res.data[i].itemname;
  141. break;
  142. }
  143. }
  144. this.setData({
  145. cashMethodName: cashMethodName,
  146. cashMethodList: res.data,
  147. });
  148. }
  149. });
  150. },
  151. submit() {
  152. app._post_form(
  153. "work/saveWork",
  154. "",
  155. this.data.detail,
  156. (res) => {
  157. if (res.code === 0) {
  158. wx.showToast({
  159. title: "添加成功",
  160. });
  161. wx.removeStorageSync("workDetail");
  162. wx.switchTab({
  163. url: "/pages/home/index/index",
  164. });
  165. }
  166. },
  167. (err) => {},
  168. (complete) => {
  169. setTimeout(() => {
  170. wx.hideLoading();
  171. }, 300);
  172. }
  173. );
  174. },
  175. // 查看二维码
  176. seeCode() {
  177. this.popup.showPopup();
  178. },
  179. // 查看地图
  180. goLocal() {
  181. let that = this;
  182. let [latitude, longitude] = [
  183. this.data.detail.coordinate.split(",")[0],
  184. this.data.detail.coordinate.split(",")[1],
  185. ];
  186. console.log(Number(latitude), Number(longitude));
  187. wx.openLocation({
  188. latitude: Number(longitude),
  189. longitude: Number(latitude),
  190. name: that.data.detail.title,
  191. address: that.data.detail.address,
  192. success: function () {
  193. console.log("success");
  194. },
  195. });
  196. },
  197. // 会员必读
  198. ready() {
  199. let _this = this;
  200. app._post_form(
  201. "wgfillinfo/apiSelectwgfillinfo",
  202. "application/json",
  203. null,
  204. function (res) {
  205. if (res.code === 0) {
  206. // _this.setData({
  207. // vipMsg: res.wgFillInfo.vipMessage
  208. // })
  209. wxparse.wxParse(
  210. "vipMsg",
  211. "html",
  212. res.wgFillInfo.vipMessage,
  213. _this,
  214. 0
  215. );
  216. }
  217. }
  218. );
  219. },
  220. //取消事件
  221. _error(e) {
  222. this.popup.hidePopup();
  223. },
  224. //确认事件
  225. _success(e) {
  226. this.popup.hidePopup();
  227. },
  228. onUnload: function () {
  229. clearInterval(this.data.timer);
  230. },
  231. });