選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

319 行
6.6 KiB

  1. // pages/addReel/addReel.js
  2. const Http = require('../../utils/HttpBasics.js')
  3. const config = require('../../config/config.js')
  4. const util = require('../../utils/util.js')
  5. Page({
  6. getSearchsText(e) {
  7. this.setData({
  8. searchsText: e.detail.value
  9. })
  10. },
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. clsIndex: 0,
  16. searchsText: '',
  17. status: -1, //卷状态
  18. list: [], //数据列表
  19. putApplyStatus: 0, //查询是否审批状态 -1表示未审批 2 表示以审批,
  20. targetAd: "",
  21. channel: 0, //已上架按钮判断条件 1是已上架
  22. pageNum: 1,
  23. statueList: [{
  24. name: '已上架',
  25. action: 'getShelfList',
  26. cls: 'save'
  27. },
  28. {
  29. name: '已作废',
  30. action: 'getcancellation',
  31. cls: 'cancellation',
  32. },
  33. {
  34. name: '已审批',
  35. action: 'getexamine',
  36. cls: 'examine',
  37. },
  38. {
  39. name: '未审批',
  40. action: 'getnoExamine',
  41. cls: 'noExamine',
  42. }
  43. ],
  44. noUpdata: true,//add是否能更改
  45. },
  46. addReel() {
  47. this.setData({
  48. noUpdata: true,
  49. })
  50. wx.navigateTo({
  51. url: '/pages/upload/upload'
  52. })
  53. },
  54. /**
  55. * 已上架
  56. */
  57. getShelfList() {
  58. this.setData({
  59. status: 0,
  60. channel: 1,
  61. pageNum: 1,
  62. targetAd: '',
  63. clsIndex: 0,
  64. noUpdata: false,
  65. })
  66. let getdata = {
  67. title: this.data.searchsText,
  68. status: this.data.status, // -1表示全部
  69. sourceType: 2,
  70. pageNum: 1,
  71. pageSize: 10,
  72. // type: 6,//6表示通用卷
  73. noUpdata: false,
  74. }
  75. Http.get({
  76. url: config.api.getShelf,
  77. data: getdata
  78. }).then(res => {
  79. const {
  80. code,
  81. data
  82. } = res
  83. if (code == 200) {
  84. this.setData({
  85. list: data.list
  86. })
  87. } else {
  88. console.log("查询出错")
  89. return
  90. }
  91. })
  92. },
  93. /**
  94. *查询卷
  95. */
  96. search() {
  97. wx.showLoading({
  98. title: '加载中',
  99. })
  100. let getdata = {
  101. title: this.data.searchsText,
  102. status: this.data.status, // -1表示全部
  103. sourceType: 2,
  104. pageNum: this.data.pageNum,
  105. pageSize: 10,
  106. type: 6, //6表示通用卷
  107. targetAd: this.data.targetAd,
  108. noUpdata: false,
  109. }
  110. if (this.putApplyStatus != 0) {
  111. getdata.putApplyStatus = this.data.putApplyStatus
  112. }
  113. Http.get({
  114. url: config.api.getCouponlist,
  115. data: getdata
  116. }).then(res => {
  117. const {
  118. code,
  119. data
  120. } = res
  121. if (code == 200) {
  122. if (this.data.pageNum == 1) {
  123. wx.hideLoading();
  124. this.setData({
  125. list: data.list
  126. })
  127. } else {
  128. if (data) {
  129. let tempList = []
  130. tempList.push(...this.data.list, ...data.list)
  131. console.log(this.data.list, tempList)
  132. wx.hideLoading();
  133. this.setData({
  134. list: tempList
  135. })
  136. } else {
  137. wx.hideLoading();
  138. return
  139. }
  140. }
  141. } else {
  142. console.log("查询出错")
  143. return
  144. }
  145. })
  146. },
  147. /**
  148. * 查全部
  149. */
  150. getAll() {
  151. this.setData({
  152. status: -1,
  153. putApplyStatus: "",
  154. targetAd: '',
  155. channel: '',
  156. pageNum: 1,
  157. })
  158. this.search()
  159. },
  160. /**
  161. * 查询已作废
  162. */
  163. getcancellation() {
  164. this.setData({
  165. status: 1,
  166. putApplyStatus: "",
  167. targetAd: '',
  168. channel: '',
  169. pageNum: 1,
  170. clsIndex: 1,
  171. noUpdata: false,
  172. })
  173. this.search()
  174. },
  175. /**
  176. * 查询以审批
  177. */
  178. getexamine() {
  179. this.setData({
  180. status: 0,
  181. putApplyStatus: 2,
  182. targetAd: '1',
  183. channel: '',
  184. pageNum: 1,
  185. clsIndex: 2,
  186. noUpdata: false,
  187. })
  188. this.search()
  189. },
  190. /**
  191. * 查询未审批
  192. */
  193. getnoExamine() {
  194. this.setData({
  195. status: 0,
  196. putApplyStatus: -1,
  197. targetAd: '',
  198. channel: '',
  199. pageNum: 1,
  200. clsIndex: 3,
  201. noUpdata: true,
  202. })
  203. this.search()
  204. },
  205. /**
  206. * 跳转到卷详情
  207. */
  208. goParticulars(e) {
  209. const data = e.currentTarget.dataset.data
  210. let postData = {
  211. title: data.title,
  212. type: "6",
  213. priceStr: data.priceStr,
  214. coverImg: data.coverImg,
  215. salePriceStr: data.salePriceStr,
  216. inventory: data.inventory,
  217. useLimitQuantity: data.useLimitQuantity,
  218. validStartDate: data.validStartDate,
  219. validEndDate: data.validStartDate,
  220. remark: data.remark,
  221. subTitle: '', //不用管管副标题 B端没用
  222. sendType: "1",
  223. remainInventory: data.remainInventory, //剩余库存
  224. validType: data.validType, //1是时间类型 2是领取后多少天有效
  225. numDays: data.validType == 2 ? data.validDays : '',
  226. validStartDate: data.validType == 1 ? util.formatTime(data.validStartDate, 'yyyy-MM-dddd') : '请选择时间',
  227. validEndDate: data.validType == 1 ? util.formatTime(data.validEndDate, 'yyyy-MM-dddd') : '请选择时间',
  228. status: data.status,
  229. id: data.id,
  230. couponId: data.couponId ? data.couponId : "",
  231. autoRefund: data.autoRefund,
  232. putApplyStatus: data.putApplyStatus, //0未提交审批 1待审批 2审批成功 3审批驳回
  233. channel: this.data.channel,
  234. noUpdata: this.data.noUpdata,
  235. useLimitRule: data.useLimitRule,
  236. coverPicture: data.coverPicture,
  237. detailPicture: data.detailPicture
  238. }
  239. console.log(postData, "postData")
  240. const tmepdata = JSON.stringify(postData)
  241. wx.setStorageSync('tmepdata', tmepdata)
  242. wx.navigateTo({
  243. url: '/pages/addReel/addReel',
  244. })
  245. },
  246. /**
  247. * 生命周期函数--监听页面加载
  248. */
  249. onLoad: function (options) {
  250. this.setData({
  251. pageNum: 1
  252. })
  253. // this.search()
  254. this.getShelfList()
  255. },
  256. /**
  257. * 生命周期函数--监听页面初次渲染完成
  258. */
  259. onReady: function () {
  260. },
  261. /**
  262. * 生命周期函数--监听页面显示
  263. */
  264. onShow: function () {
  265. console.log(this.data.clsIndex, "???")
  266. switch (this.data.clsIndex) {
  267. case 0: this.getShelfList(); break;
  268. case 1: this.getcancellation(); break;
  269. case 2: this.getexamine(); break;
  270. case 3: this.getnoExamine(); break;
  271. }
  272. },
  273. /**
  274. * 生命周期函数--监听页面隐藏
  275. */
  276. onHide: function () {
  277. },
  278. /**
  279. * 生命周期函数--监听页面卸载
  280. */
  281. onUnload: function () {
  282. },
  283. /**
  284. * 页面相关事件处理函数--监听用户下拉动作
  285. */
  286. onPullDownRefresh: function () {
  287. },
  288. /**
  289. * 页面上拉触底事件的处理函数
  290. */
  291. onReachBottom: function () {
  292. this.setData({
  293. pageNum: this.data.pageNum + 1
  294. })
  295. this.search()
  296. },
  297. /**
  298. * 用户点击右上角分享
  299. */
  300. onShareAppMessage: function () {
  301. }
  302. })