学员端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
8.2 KiB

  1. <template>
  2. <view class="myData pad" id="app">
  3. <topNavbar title=""></topNavbar>
  4. <view class="topText">
  5. <view class="h3">专属您的</view>
  6. <view class="h4">学车数据</view>
  7. </view>
  8. <view class="card">
  9. <view class="row">
  10. <view class="leftCon">
  11. <view class="icon">
  12. <image src="@/static/images/userCenter/ic_jiaxiao.png" mode=""></image>
  13. </view>
  14. <view class="text">我的驾校</view>
  15. </view>
  16. <view class="value">翔力驾校</view>
  17. </view>
  18. <view class="row">
  19. <view class="leftCon">
  20. <view class="icon">
  21. <image src="@/static/images/userCenter/ic_jiaolian.png" mode=""></image>
  22. </view>
  23. <view class="text">我的教练</view>
  24. </view>
  25. <view class="value">xxx</view>
  26. </view>
  27. <view class="row">
  28. <view class="leftCon">
  29. <view class="icon">
  30. <image src="@/static/images/userCenter/ic_chexing.png" mode=""></image>
  31. </view>
  32. <view class="text">所学车型</view>
  33. </view>
  34. <view class="value">xxx</view>
  35. </view>
  36. <view class="row">
  37. <view class="leftCon">
  38. <view class="icon">
  39. <image src="@/static/images/userCenter/ic_shijian.png" mode=""></image>
  40. </view>
  41. <view class="text">报名时间</view>
  42. </view>
  43. <view class="value">xxx</view>
  44. </view>
  45. </view>
  46. <!-- 学驾共历时 -->
  47. <view class="card">
  48. <view class="chart_row">
  49. <view class="leftText">
  50. <view class="lab">学驾共历时</view>
  51. <view class="val">33</view>
  52. </view>
  53. <view class="rightChart">
  54. <ringChart />
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 考试通过率 -->
  59. <view class="card">
  60. <view class="chart_row">
  61. <view class="leftText" style="width: 200rpx;">
  62. <view class="lab">考试通过率</view>
  63. <view class="val">90%</view>
  64. </view>
  65. <view class="rightChart pad28">
  66. <view class="blueBg">
  67. <columnChart/>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="flex-b">
  73. <view class="count card">
  74. <view class="lab">实操练习次数</view>
  75. <view class="val">20</view>
  76. </view>
  77. <view class="count card">
  78. <view class="lab">模拟训练次数</view>
  79. <view class="val">20</view>
  80. </view>
  81. </view>
  82. <view class="btnBorder" @click="destImgFn">立即分享</view>
  83. <!-- <button @click="shareFn" open-type="share">立即分享</button> -->
  84. <canvas canvas-id="canvas" style="width: 350px; height: 350px;" class="canvas">3333</canvas>
  85. <view class="img" style="width: 300px; height: 300px;">
  86. <image :src="shareImageUrl" mode=""></image>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import ringChart from './ringChart.vue'
  92. import columnChart from './columnChart'
  93. export default {
  94. components: { ringChart, columnChart },
  95. data() {
  96. return {
  97. shareImageUrl: ''
  98. }
  99. },
  100. onReady() {
  101. this.destImgFn()
  102. },
  103. methods: {
  104. captureCanvas() {
  105. // 获取 Canvas 组件实例
  106. const canvas = uni.createCanvasContext('myCanvas', this);
  107. // 绘制需要的内容
  108. canvas.setFontSize(20);
  109. canvas.fillText('Hello, Canvas!', 50, 50);
  110. // 绘制完成后执行截屏操作
  111. canvas.draw(true, () => {
  112. uni.canvasToTempFilePath({
  113. canvasId: 'myCanvas',
  114. fileType: 'png',
  115. success: (res) => {
  116. console.log('截屏成功', res.tempFilePath);
  117. },
  118. fail: (err) => {
  119. console.log('截屏失败', err);
  120. }
  121. }, this);
  122. });
  123. },
  124. destImgFn() {
  125. this.$nextTick(()=>{
  126. // uni.canvasToTempFilePath({
  127. // x: 0,
  128. // y: 0,
  129. // width: 350,
  130. // height: 350,
  131. // destWidth: 350,
  132. // destHeight: 350,
  133. // canvasId: 'canvas',
  134. // success: function(res) {
  135. // // 在H5平台下,tempFilePath 为 base64
  136. // console.log(res.tempFilePath)
  137. // }
  138. // },this)
  139. // return
  140. let _this = this
  141. uni.createSelectorQuery().select('#app').boundingClientRect((rect) => {
  142. console.log(rect)
  143. const context = uni.createCanvasContext('canvas')
  144. context.draw(true, () => {
  145. setTimeout(()=>{
  146. uni.canvasToTempFilePath({
  147. x: 0,
  148. y: 0,
  149. fileType:'png',
  150. width: 200,
  151. height: 200,
  152. // destWidth: rect.width * uni.getSystemInfoSync().pixelRatio,
  153. // destHeight: rect.height * uni.getSystemInfoSync().pixelRatio,
  154. canvasId: 'canvas',
  155. success: (res) => {
  156. console.log('截图成功')
  157. console.log(res)
  158. uni.showToast({
  159. title: '截图成功',
  160. icon: 'none'
  161. })
  162. // uni.hideToast()
  163. // 将截屏图片路径保存至storage或全局变量,以便后续分享使用
  164. _this.shareImageUrl = res.tempFilePath
  165. console.log(_this.shareImageUrl)
  166. },
  167. fail: (error) => {
  168. console.log('截图失败')
  169. console.log(error)
  170. // uni.hideToast()
  171. uni.showToast({
  172. title: '截图失败',
  173. icon: 'none'
  174. })
  175. },
  176. })
  177. },2000)
  178. })
  179. }).exec()
  180. })
  181. },
  182. shareFn() {
  183. let _this = this
  184. // uni.share({
  185. // provider: "weixin",
  186. // scene: "WXSceneSession",
  187. // type: 2,
  188. // imageUrl: _this.shareImageUrl,
  189. // success: function (res) {
  190. // console.log("success:" + JSON.stringify(res));
  191. // },
  192. // fail: function (err) {
  193. // console.log("fail:" + JSON.stringify(err));
  194. // }
  195. // });
  196. uni.showShareMenu({
  197. withShareTicket: true,
  198. success: () => {
  199. uni.showShareImageMenu({
  200. path: _this.shareImageUrl,
  201. success: (res) => {
  202. console.log('分享成功', res)
  203. },
  204. fail: (error) => {
  205. console.log('分享失败', error)
  206. }
  207. })
  208. }
  209. })
  210. },
  211. // 在分享按钮的点击事件中调用分享API
  212. onShareImageBtnClick() {
  213. wx.showShareMenu({
  214. withShareTicket: true,
  215. success: () => {
  216. wx.shareAppMessage({
  217. imageUrl: '/image/share-image.jpg',
  218. success: (res) => {
  219. console.log('分享成功', res)
  220. },
  221. fail: (error) => {
  222. console.log('分享失败', error)
  223. }
  224. })
  225. }
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="scss" scoped>
  232. .myData {
  233. width: 100%;
  234. background: url('http://192.168.1.20:81/zhili/image/20230818/409dca21dfec44eb8477e056ee23e437.png') #f6f6f6 no-repeat;
  235. background-size: 100% 544rpx;
  236. min-height: 100vh;
  237. font-size: 28rpx;
  238. padding-bottom: 40rpx;
  239. .topText {
  240. padding: 56rpx 34rpx 84rpx 34rpx;
  241. color: #fff;
  242. font-weight: 600;
  243. .h3 {
  244. font-size: 42rpx;
  245. }
  246. .h4 {
  247. font-size: 64rpx;
  248. }
  249. }
  250. .card {
  251. padding: 0 24rpx;
  252. margin-bottom: 20rpx;
  253. .row {
  254. display: flex;
  255. border-bottom: 2rpx solid #E8E9EC;
  256. height: 102rpx;
  257. align-items: center;
  258. .leftCon {
  259. display: flex;
  260. align-items: center;
  261. .icon {
  262. width: 40rpx;
  263. height: 40rpx;
  264. }
  265. .text {
  266. font-size: 28rpx;
  267. padding: 0 40rpx 0 12rpx;
  268. }
  269. }
  270. .value {
  271. font-size: 28rpx;
  272. color: #1989FA;
  273. flex: 1;
  274. }
  275. }
  276. }
  277. .count {
  278. width: 48%;
  279. height: 196rpx;
  280. background: #FFFFFF;
  281. border-radius: 16rpx;
  282. text-align: center;
  283. .lab {
  284. margin: 36rpx 0 28rpx 0;
  285. }
  286. .val {
  287. font-weight: 500;
  288. font-size: 40rpx;
  289. color: $themC;
  290. }
  291. }
  292. .btnBorder {
  293. width: 396rpx;
  294. margin: 48rpx auto 0 auto;
  295. }
  296. }
  297. .chart_row {
  298. height: 300rpx;
  299. border-radius: 16rpx;
  300. display: flex;
  301. .leftText {
  302. width: 270rpx;
  303. display: flex;
  304. flex-direction: column;
  305. align-items: center;
  306. justify-content: center;
  307. .lab {
  308. margin: 0rpx 0 24rpx 0;
  309. }
  310. .val {
  311. font-weight: 500;
  312. font-size: 40rpx;
  313. color: $themC;
  314. }
  315. }
  316. .rightChart {
  317. width: 0;
  318. flex: 1;
  319. &.pad28 {
  320. padding: 28rpx 0;
  321. }
  322. .blueBg {
  323. padding: 20rpx 0 10rpx 0;
  324. width: 100%;
  325. height: 100%;
  326. background-color: #F2F8FF;
  327. }
  328. }
  329. }
  330. .img {
  331. width: 100vw;
  332. height: 100vh;
  333. }
  334. </style>