index.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. // pages/search/index.ts
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. /// 底部安全区域
  8. safeBottom: getApp().globalData.safeBottom,
  9. /// tabs
  10. tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
  11. /// tab索引
  12. active: 0,
  13. /// 形状
  14. shapes: [{id: 1, name: '圆明亮形', isCheck: true},
  15. {id: 2, name: '公主方形', isCheck: false},
  16. {id: 3, name: '心形', isCheck: false},
  17. {id: 4, name: '马眼形', isCheck: false},
  18. {id: 5, name: '三角形', isCheck: false},
  19. {id: 6, name: '垫形', isCheck: false},
  20. {id: 7, name: '祖母绿形', isCheck: false},
  21. {id: 8, name: '梨形', isCheck: false},
  22. {id: 9, name: '椭圆形', isCheck: false},
  23. {id: 10, name: '长方形', isCheck: false},
  24. {id: 11, name: '雷迪恩形', isCheck: false},
  25. {id: 12, name: '阿斯切形', isCheck: false},
  26. {id: 13, name: '其他', isCheck: false}],
  27. /// 选中形状
  28. shape: ['1'],
  29. /// 颜色
  30. colors: [{id: 1, name: 'D', isCheck: true},
  31. {id: 2, name: 'E', isCheck: false},
  32. {id: 3, name: 'F', isCheck: false},
  33. {id: 4, name: 'G', isCheck: false},
  34. {id: 5, name: 'H', isCheck: false},
  35. {id: 6, name: 'I', isCheck: false},
  36. {id: 7, name: 'J', isCheck: false},
  37. {id: 8, name: 'K', isCheck: false},
  38. {id: 9, name: 'L', isCheck: false},
  39. {id: 10, name: 'M', isCheck: false},
  40. {id: 11, name: 'N', isCheck: false},
  41. {id: 12, name: 'O', isCheck: false},
  42. {id: 13, name: 'P', isCheck: false},
  43. {id: 14, name: 'Q', isCheck: false},
  44. {id: 15, name: 'R', isCheck: false},
  45. {id: 16, name: 'S', isCheck: false},
  46. {id: 17, name: 'T', isCheck: false},
  47. {id: 18, name: 'U', isCheck: false},
  48. {id: 19, name: 'W', isCheck: false},
  49. {id: 20, name: 'V', isCheck: false},
  50. {id: 21, name: 'X', isCheck: false},
  51. {id: 22, name: 'Y', isCheck: false},
  52. {id: 23, name: 'Z', isCheck: false},
  53. {id: 24, name: '彩色', isCheck: false}],
  54. /// 选中形状
  55. color: [1],
  56. /// 净度
  57. neatness: [{id: 1, name: 'FL', isCheck: true},
  58. {id: 2, name: 'IF', isCheck: false},
  59. {id: 3, name: 'VVS1', isCheck: false},
  60. {id: 4, name: 'VVS2', isCheck: false},
  61. {id: 5, name: 'VS1', isCheck: false},
  62. {id: 6, name: 'VS2', isCheck: false},
  63. {id: 7, name: 'SI1', isCheck: false},
  64. {id: 8, name: 'SI2', isCheck: false},
  65. {id: 9, name: 'SI3', isCheck: false},
  66. {id: 10, name: 'I1', isCheck: false},
  67. {id: 11, name: 'I2', isCheck: false},
  68. {id: 12, name: 'I3', isCheck: false}],
  69. /// 选中净度
  70. neatnes: 1,
  71. /// 切工
  72. qiegongs: [{id: 1, name: 'EX', isCheck: true},
  73. {id: 2, name: 'VG', isCheck: false},
  74. {id: 3, name: 'G', isCheck: false},
  75. {id: 4, name: 'F', isCheck: false},
  76. {id: 5, name: 'P', isCheck: false}],
  77. /// 选中切工
  78. qiegong: 1,
  79. /// 对称
  80. duichengs: [{id: 1, name: 'EX', isCheck: true},
  81. {id: 2, name: 'VG', isCheck: false},
  82. {id: 3, name: 'G', isCheck: false},
  83. {id: 4, name: 'F', isCheck: false},
  84. {id: 5, name: 'P', isCheck: false}],
  85. duicheng: 1,
  86. /// 抛光
  87. paoguangs: [{id: 1, name: 'EX', isCheck: true},
  88. {id: 2, name: 'VG', isCheck: false},
  89. {id: 3, name: 'G', isCheck: false},
  90. {id: 4, name: 'F', isCheck: false},
  91. {id: 5, name: 'P', isCheck: false}],
  92. paoguang: 1,
  93. /// 莹光
  94. yingguangs: [{id: 1, name: '无', isCheck: true},
  95. {id: 2, name: '微弱', isCheck: false},
  96. {id: 3, name: '中等', isCheck: false},
  97. {id: 4, name: '强', isCheck: false},
  98. {id: 5, name: '极强', isCheck: false}],
  99. /// 选中莹光
  100. yingguang: 1,
  101. /// 证书
  102. certificates: [{id: 1, name: 'GIA', isCheck: true},
  103. {id: 2, name: 'NGTC', isCheck: false},
  104. {id: 3, name: 'HRD', isCheck: false},
  105. {id: 4, name: 'IGI', isCheck: false},
  106. {id: 5, name: 'EGL', isCheck: false},
  107. {id: 6, name: 'AGS', isCheck: false},
  108. {id: 7, name: 'NGIC', isCheck: false},
  109. {id: 8, name: 'Others', isCheck: false}],
  110. /// 选中证书
  111. certificate: 1,
  112. /// 币种
  113. currencys: [{id: 1, name: '人民币(¥)', isCheck: true},
  114. {id: 2, name: '美元($)', isCheck: false}],
  115. currency: 1,
  116. /// 最小重量
  117. minweight: 0.00,
  118. /// 最大重量
  119. maxweight: 0.00
  120. },
  121. /**
  122. * tab触发事件
  123. */
  124. onTabChange(e: any) {
  125. /// 设置激活项
  126. this.setData({ active: e.detail.index })
  127. },
  128. /**
  129. * 返回上层视图
  130. */
  131. backToParent() {
  132. /// 返回上层视图
  133. wx.navigateBack()
  134. },
  135. /// 按钮点击事件
  136. onButtonPressed(e: any) {
  137. /// 数据拼接
  138. const ids = (<string> e.target.id).split(' ')
  139. const id = (<string> e.target.id).split(' ')[0]
  140. const index = <number> <unknown>ids[1]
  141. switch (id) {
  142. case 'shape': /// 形状
  143. this.setData({ shapes: this.data.shapes.map(item => {
  144. if (item.id == index) { item.isCheck = !item.isCheck }
  145. return item
  146. }) })
  147. /// 赋值
  148. this.setData({ shape: this.data.shapes.map(item => {
  149. return item.id.toString()
  150. }) })
  151. break;
  152. case 'currency':
  153. this.setData({ currencys: this.data.currencys.map(item => {
  154. if (item.id == index) {
  155. item.isCheck = true
  156. /// 赋值
  157. this.setData({ currency: item.id })
  158. } else {
  159. item.isCheck = false
  160. }
  161. return item
  162. }) })
  163. break;
  164. case 'color': /// 颜色
  165. this.setData({ colors: this.data.colors.map(item => {
  166. if (item.id == index) { item.isCheck = !item.isCheck }
  167. return item
  168. }) })
  169. /// 赋值
  170. this.setData({ color: this.data.colors.map(item => { return item.id }) })
  171. break;
  172. case 'neatness': /// 净度
  173. this.setData({ neatness: this.data.neatness.map(item => {
  174. if (item.id == index) {
  175. item.isCheck = true
  176. /// 赋值
  177. this.setData({ neatnes: item.id })
  178. } else {
  179. item.isCheck = false
  180. }
  181. return item
  182. }) })
  183. break;
  184. case 'qiegong': /// 切工
  185. this.setData({ qiegongs: this.data.qiegongs.map(item => {
  186. if (item.id == index) {
  187. item.isCheck = true
  188. /// 赋值
  189. this.setData({ qiegong: item.id })
  190. } else {
  191. item.isCheck = false
  192. }
  193. return item
  194. }) })
  195. break;
  196. case 'duicheng': /// 对称
  197. this.setData({ duichengs: this.data.duichengs.map(item => {
  198. if (item.id == index) {
  199. item.isCheck = true
  200. /// 赋值
  201. this.setData({ duicheng: item.id })
  202. } else {
  203. item.isCheck = false
  204. }
  205. return item
  206. }) })
  207. break;
  208. case 'polishing': /// 抛光
  209. this.setData({ paoguangs: this.data.paoguangs.map(item => {
  210. if (item.id == index) {
  211. item.isCheck = true
  212. /// 赋值
  213. this.setData({ polishing: item.id })
  214. } else {
  215. item.isCheck = false
  216. }
  217. return item
  218. }) })
  219. break;
  220. case 'yingguang': /// 荧光
  221. this.setData({ yingguangs: this.data.yingguangs.map(item => {
  222. if (item.id == index) {
  223. item.isCheck = true
  224. /// 赋值
  225. this.setData({ yingguang: item.id })
  226. } else {
  227. item.isCheck = false
  228. }
  229. return item
  230. }) })
  231. break;
  232. case 'certificate': /// 证书
  233. this.setData({ certificates: this.data.certificates.map(item => {
  234. if (item.id == index) {
  235. item.isCheck = true
  236. /// 赋值
  237. this.setData({ certificate: item.id })
  238. } else {
  239. item.isCheck = false
  240. }
  241. return item
  242. }) })
  243. break;
  244. case 'search': /// 搜索
  245. /// 搜索页面跳转
  246. this.goToSearch()
  247. break;
  248. case 'clear': break;
  249. default: break;
  250. }
  251. },
  252. /// 重量范围值更改
  253. syncNumRange(e: any) {
  254. this.setData({
  255. minweight: e.detail.value[0],
  256. maxweight: e.detail.value[1],
  257. })
  258. },
  259. /// 搜索页面跳转
  260. goToSearch() {
  261. /// 数据拼接
  262. const info = {
  263. category: this.data.tabs[this.data.active].id,
  264. zsshapetype: this.data.shape,
  265. zsclaritytype: this.data.neatnes,
  266. zscuttype: this.data.qiegong,
  267. zssymmetrytype: this.data.duicheng,
  268. zspolishtype: this.data.paoguang,
  269. zsfluorescencetype: this.data.yingguang,
  270. zscurrencytype: this.data.currency,
  271. zscerttype: this.data.certificate,
  272. zscolortype: this.data.color,
  273. weight1: this.data.minweight,
  274. weight2: this.data.maxweight
  275. }
  276. /// 页面跳转
  277. wx.switchTab({
  278. url: '/pages/trade/index',
  279. /// 加载成功
  280. success: () => {
  281. /// 缓存数据
  282. wx.setStorageSync('TradeParams', JSON.stringify(info))
  283. }
  284. })
  285. },
  286. /**
  287. * 生命周期函数--监听页面加载
  288. */
  289. onLoad() {
  290. },
  291. /**
  292. * 生命周期函数--监听页面初次渲染完成
  293. */
  294. onReady() {
  295. },
  296. /**
  297. * 生命周期函数--监听页面显示
  298. */
  299. onShow() {
  300. },
  301. /**
  302. * 生命周期函数--监听页面隐藏
  303. */
  304. onHide() {
  305. },
  306. /**
  307. * 生命周期函数--监听页面卸载
  308. */
  309. onUnload() {
  310. },
  311. /**
  312. * 页面相关事件处理函数--监听用户下拉动作
  313. */
  314. onPullDownRefresh() {
  315. },
  316. /**
  317. * 页面上拉触底事件的处理函数
  318. */
  319. onReachBottom() {
  320. },
  321. /**
  322. * 用户点击右上角分享
  323. */
  324. onShareAppMessage() {
  325. }
  326. })