index.nvue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="live-pusher-box" :style="{width: width + 'px',height: height + 'px'}">
  3. <!-- <live-pusher id="livePusher" ref="livePusher" mode="FHD" beauty="0" whiteness="0"
  4. device-position="back" :auto-focus="true" :muted="true" :enable-camera="true" :enable-mic="true"
  5. :zoom="true" :style="{flex: 1 ,width: width + 'px',display:'none'}" >
  6. </live-pusher> -->
  7. <Ba-CameraView ref="cameraView" :load="loadData" v-if="isShowCamera" :style="{flex: 1,width: width + 'px',display:'none'}" >
  8. </Ba-CameraView>
  9. <cover-view class="cover-view" :style="{width: width + 'px'}">
  10. <cover-view class="uni-nav-bar" :style="{width: width + 'px'}">
  11. <cover-view :style="{height: statusBarHeight,width: width + 'px'}"></cover-view>
  12. <cover-view class="uni-nav-barbox" :style="{width: width + 'px'}">
  13. <cover-image class="uni-nav-back" src="@/static/image/ai_right_icon.png" mode="aspectFill" @click="back"></cover-image>
  14. <cover-view class="flex-center">
  15. <cover-view class="uni-nav-title" @click="navTo()">
  16. <text class="uni-nav-title-t">使用教程</text>
  17. <cover-image class="ques" :src="baseUrl+'/images/ques.png'" mode="aspectFill"></cover-image>
  18. </cover-view>
  19. <!-- #ifdef APP-PLUS -->
  20. <cover-view class="uni-nav-title" style="margin-left: 20rpx;" @click="goShare">
  21. <text class="uni-nav-title-t">分享</text>
  22. <cover-image class="ques" src="@/static/images/white-share.png" mode="aspectFill"></cover-image>
  23. </cover-view>
  24. <!-- #endif -->
  25. </cover-view>
  26. </cover-view>
  27. </cover-view>
  28. <text class="title" :style="{marginTop: marginTop + 'px'}" @click="startPreview">请拍摄舌面</text>
  29. <text class="tips">舌尖放松,舌面平展,舌尖略向下,口张大不要太用力</text>
  30. <cover-view class="imagebox" :style="{width: width + 'px'}">
  31. <cover-image class="tongue" src="@/static/images/tongue.png" mode="aspectFill"></cover-image>
  32. </cover-view>
  33. </cover-view>
  34. <!-- 分享弹窗 -->
  35. <view>
  36. <u-popup :show="showShare" @close="showShare = false" >
  37. <share-box :shareItem="shareItem" :operate="operate" @closeShare='showShare = false' ></share-box>
  38. </u-popup>
  39. </view>
  40. <view class="camera-footer" id="camera-footer" :style="{width: width + 'px'}">
  41. <view class="usenum">
  42. <text class="usenum-t">当前可免费试用</text>
  43. <text class="usenum-t" style="color: #F54D04;padding: 0;">{{counts || 0}}</text>
  44. <text class="usenum-t">次</text>
  45. </view>
  46. <view class="camera-options" :style="{width: width + 'px'}">
  47. <view class="camera-options-left camera-item" @click="handleAlbum">
  48. <image :src="baseUrl+'/images/album_icon.png'" mode="scaleToFill" style="width: 65rpx;height:60rpx;margin-bottom: 21rpx;"></image>
  49. <text class="camera-item-t">相册上传</text>
  50. </view>
  51. <view class="camera-options-center camera-item" @click="handleShutter">
  52. <view class="photograph-btn"></view>
  53. </view>
  54. <view class="camera-options-ritht camera-item" @click="handleReversal">
  55. <image :src="baseUrl+'/images/tongue_info.png'" mode="scaleToFill" style="width: 67rpx;height:60rpx;margin-bottom: 21rpx;"></image>
  56. <text class="camera-item-t">切换摄像头</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import shareBox from "@/components/share-box/share-boxN.vue"
  64. import {getCount} from '@/api/healthTongue.js'
  65. import { premissionCheck } from "@/js_sdk/wa-permission/permission.js"
  66. // 这个组件仅限APP使用!!!
  67. export default {
  68. components: {
  69. shareBox
  70. },
  71. data() {
  72. return {
  73. baseUrl:uni.getStorageSync('requestPath'),
  74. height: uni.getSystemInfoSync().screenHeight,
  75. width: uni.getSystemInfoSync().screenWidth,
  76. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  77. livePusher: null,
  78. ready: true,
  79. cameraHeight: '', //相机画面宽度
  80. coverImage: null,
  81. counts: 0,
  82. marginTop: uni.getSystemInfoSync().statusBarHeight + uni.upx2px(130),
  83. device: 'back',
  84. cameraContext: null,
  85. shutterShow: false,
  86. menuLeft: '100%',
  87. loadData: { //配置
  88. isToast: false,
  89. isShowVibrate:false,
  90. },
  91. liveDisplay:"none",
  92. showShare:false,
  93. shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
  94. operate: ['WXSceneSession','WXSceneTimeline'],
  95. isShowCamera:false,
  96. }
  97. },
  98. created(){
  99. let that=this;
  100. uni.$on('navigateBack', function(data) {
  101. that.handleReversal();
  102. });
  103. },
  104. onLoad() {
  105. this.getCount();
  106. if(!plus.runtime.isAgreePrivacy()) {
  107. uni.showToast({title: "请同意隐私政策",icon: "none"});
  108. return;
  109. }
  110. this.requestPressmition();
  111. },
  112. onUnload() {
  113. uni.$off('navigateBack');
  114. },
  115. onReady() {
  116. },
  117. methods: {
  118. navTo() {
  119. uni.navigateTo({
  120. url: "/pages/user/tongue/ques"
  121. })
  122. },
  123. goShare() {
  124. // #ifdef APP-PLUS
  125. this.shareItem.title= "AI舌诊";
  126. this.shareItem.imageUrl="/static/image/home1/icon/aiTongue.png";
  127. this.shareItem.isMini=true;
  128. this.shareItem.path='/pages_user/tongue/index';
  129. let cdn=uni.getStorageSync('h5Path');
  130. this.shareItem.url=cdn+'/pages/user/tongue/index';
  131. this.showShare=true;
  132. // #endif
  133. },
  134. getCount(){
  135. getCount().then(
  136. res => {
  137. if(res.code==200){
  138. this.counts=res.data;
  139. }else{
  140. uni.showToast({
  141. icon:'none',
  142. title: "请求失败",
  143. });
  144. }
  145. },
  146. rej => {}
  147. );
  148. },
  149. startPreview() {
  150. this.livePusher.startPreview({
  151. success: () => {
  152. switch (plus.os.name) {
  153. case 'Android':
  154. break;
  155. case 'iOS':
  156. this.livePusher.switchCamera()
  157. break
  158. }
  159. },
  160. fail: (err) => {
  161. console.log(err)
  162. }
  163. });
  164. },
  165. // 返回
  166. back(){
  167. uni.navigateBack();
  168. },
  169. // 快门
  170. handleShutter() {
  171. if (this.ready) {
  172. this.ready = false;
  173. let options={scaleW:403,scaleH:620,isCrop:false};
  174. this.$refs.cameraView.takePicture((res) => {
  175. this.ready = true;
  176. const filePath=res.data.path;
  177. plus.io.resolveLocalFileSystemURL(filePath, (entry) => {
  178. let url= entry.toLocalURL();
  179. uni.navigateTo({
  180. url:"/pages/user/tongue/photoPreview?url="+url
  181. });
  182. }, (error) => {
  183. console.error('Failed to resolve file system URL:', error);
  184. });
  185. },options);
  186. }
  187. },
  188. // 相册
  189. async handleAlbum() {
  190. // #ifdef APP-PLUS
  191. let result = await premissionCheck("EXTERNAL_STORAGE");
  192. if(result == 1) {
  193. uni.chooseImage({
  194. count: 1, //默认9
  195. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  196. sourceType: ['album'], //从相册选择
  197. success: (res) => {
  198. uni.setStorageSync("tongueUrl",res.tempFilePaths[0])
  199. let url= res.tempFilePaths[0]
  200. uni.navigateTo({
  201. url:"/pages/user/tongue/photoPreview?url="+url
  202. })
  203. }
  204. });
  205. }
  206. // #endif
  207. },
  208. // 反转摄像头
  209. handleReversal() {
  210. this.$refs.cameraView.switchCamera((res) => {
  211. });
  212. },
  213. // 舌诊记录
  214. handleReportlist() {
  215. uni.navigateTo({
  216. url: "/pages/user/tongue/tongueList"
  217. })
  218. },
  219. setListener() {
  220. this.$refs.cameraView.setListener((res) => {
  221. if (res.action == "error") {
  222. this.showToast(res.msg)
  223. }
  224. });
  225. },
  226. async requestPressmition(){
  227. let result = await premissionCheck("CAMERA_EXTERNAL_STORAGE");
  228. if(result == 1) {
  229. setTimeout(()=>{
  230. this.isShowCamera=true;
  231. },500)
  232. }
  233. },
  234. }
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. @mixin u-flex($flexD, $alignI, $justifyC) {
  239. display: flex;
  240. flex-direction: $flexD;
  241. align-items: $alignI;
  242. justify-content: $justifyC;
  243. }
  244. .flex-center {
  245. @include u-flex(row, center, center);
  246. }
  247. .live-pusher-box {
  248. @include u-flex(column, center, center);
  249. }
  250. .imagebox {
  251. margin-top: 60rpx;
  252. @include u-flex(column, center, center);
  253. }
  254. .tongue {
  255. width: 531rpx;
  256. height: 592rpx;
  257. }
  258. .cover-view {
  259. width: 100%;
  260. position: absolute;
  261. top: 0;
  262. left: 0;
  263. @include u-flex(column, center, center);
  264. }
  265. .title {
  266. // margin-top: calc(var(--status-bar-height) + 130rpx);
  267. font-family: SourceHanSansCN-Medium;
  268. font-weight: 500;
  269. font-size: 43rpx;
  270. color: #FFFFFF;
  271. text-align: center;
  272. }
  273. .tips {
  274. margin-top: 38rpx;
  275. font-family: SourceHanSansSC-Regular;
  276. font-weight: 400;
  277. font-size: 24rpx;
  278. color: #FFFFFF;
  279. text-align: center;
  280. }
  281. .uni-nav-bar {
  282. position: fixed;
  283. top: 0;
  284. left: 0;
  285. width: 100%;
  286. z-index: 999;
  287. overflow: hidden;
  288. font-family: PingFang SC, PingFang SC;
  289. font-weight: 500;
  290. color: #FFFFFF;
  291. .uni-nav-barbox {
  292. width: 100%;
  293. height: 88rpx;
  294. padding: 0 24rpx;
  295. // box-sizing: border-box;
  296. @include u-flex(row, center, space-between);
  297. position: relative;
  298. font-size: 24rpx;
  299. }
  300. .uni-nav-title-t {
  301. font-family: SourceHanSansSC;
  302. font-weight: 400;
  303. color: #FFFFFF;
  304. /* #ifdef APP-PLUS */
  305. font-size: 32rpx;
  306. /* #endif */
  307. /* #ifndef APP-PLUS */
  308. font-size: 14px;
  309. /* #endif */
  310. }
  311. .uni-nav-title {
  312. // flex-shrink: 0;
  313. font-family: SourceHanSansSC;
  314. font-weight: 400;
  315. color: #FFFFFF;
  316. /* #ifdef APP-PLUS */
  317. font-size: 32rpx;
  318. /* #endif */
  319. /* #ifndef APP-PLUS */
  320. font-size: 14px;
  321. /* #endif */
  322. @include u-flex(row, center, flex-start);
  323. .ques {
  324. // flex-shrink: 0;
  325. width: 33rpx;
  326. height: 33rpx;
  327. margin-left: 9rpx;
  328. }
  329. }
  330. .uni-nav-back {
  331. height: 32rpx;
  332. width: 32rpx;
  333. }
  334. }
  335. .camera-footer {
  336. background-color: #000;
  337. overflow: hidden;
  338. position: fixed;
  339. bottom: 0;
  340. left: 0;
  341. }
  342. .usenum {
  343. text-align: center;
  344. @include u-flex(row, center, center);
  345. .usenum-t {
  346. font-family: SourceHanSansCN;
  347. font-weight: 400;
  348. font-size: 19rpx;
  349. color: #FFFFFF;
  350. padding: 14rpx;
  351. }
  352. }
  353. .camera-options {
  354. width: 100%;
  355. padding-top: 13rpx;
  356. padding-bottom: 60rpx;
  357. // box-sizing: border-box;
  358. @include u-flex(row, center, space-around);
  359. }
  360. .camera-item {
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. }
  365. .camera-item-t {
  366. font-family: SourceHanSansCN;
  367. font-weight: 400;
  368. font-size: 27rpx;
  369. color: #FFFFFF;
  370. }
  371. .camera-options-center {
  372. width: 131rpx;
  373. height: 131rpx;
  374. border-radius: 50%;
  375. border: 3px solid #FFFFFF;
  376. display: flex;
  377. align-items: center;
  378. justify-content: center;
  379. }
  380. .photograph-btn {
  381. width: 109rpx;
  382. height: 109rpx;
  383. background: #F54D04;
  384. border-radius: 50%;
  385. }
  386. </style>