index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. const app = getApp();
  3. Page({
  4. init: true,
  5. data: {
  6. selectVideo: [],
  7. showActionsheet: false,
  8. canIUseGetUserProfile: false,
  9. groups: [
  10. { text: '拍照', value: 1 },
  11. { text: '选择照片', value: 2 },
  12. ]
  13. },
  14. onLoad: function () {
  15. },
  16. onShow() {
  17. let p = {}
  18. let D = JSON.parse(wx.getStorageSync('generated') || "[]");
  19. if (D) {
  20. app.globalData.generate = D;
  21. p.selectVideo = D;
  22. }
  23. if (wx.getUserProfile)
  24. p.canIUseGetUserProfile = true
  25. this.setData(p);
  26. },
  27. tabsChange: function (id) {
  28. console.log("-->", id);
  29. },
  30. clickAdd: function () {
  31. this.init = false;
  32. this.setData({
  33. showActionsheet: true
  34. })
  35. },
  36. btnClick(e) {
  37. console.log("--------")
  38. let _this = this;
  39. let config = {
  40. count: 1,
  41. success: function () {
  42. _this.setData({
  43. showActionsheet: false
  44. }, () => {
  45. wx.showLoading({title:"人脸识别中..."})
  46. let time = setTimeout(() => {
  47. clearTimeout(time);
  48. wx.hideLoading()
  49. wx.navigateTo({
  50. url: "/pages/selectVideo/selectVideo"
  51. });
  52. }, Math.random() * 2000)
  53. })
  54. }
  55. }
  56. if (e.detail.value === 1) {
  57. config.sourceType = ['camera'];
  58. } else if (e.detail.value === 2) {
  59. config.sourceType = ['album'];
  60. }
  61. wx.chooseImage(config)
  62. }
  63. });