index.js 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Page({
  2. data: {
  3. camera: "../../assets/try/camera.png"
  4. },
  5. // 拍照
  6. takePhoto () {
  7. const ctx = wx.createCameraContext();
  8. ctx.takePhoto({
  9. quality: 'high',
  10. success: res => {
  11. // 旋转图片
  12. var canvas = wx.createContext();
  13. canvas.rotate(90 * Math.PI / 180);
  14. canvas.drawImage(res.tempImagePath);
  15. wx.drawCanvas({
  16. canvasId: "canvas",
  17. success: res => this.see(res.tempImagePath)
  18. })
  19. // this.see(res.tempImagePath)
  20. }
  21. })
  22. },
  23. error (e) {
  24. console.log(e.detail)
  25. },
  26. // 预览
  27. see (data) {
  28. wx.previewImage({
  29. current: data, // 当前显示图片的http链接
  30. urls: [data] // 需要预览的图片http链接列表
  31. })
  32. },
  33. onLoad: function (options) {
  34. },
  35. onReady: function () {
  36. },
  37. onShow: function () {
  38. },
  39. onHide: function () {
  40. },
  41. onUnload: function () {
  42. },
  43. onPullDownRefresh: function () {
  44. },
  45. onReachBottom: function () {
  46. },
  47. })