ChatingActionBar.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <view class="chat_action_bar">
  3. <u-row class="action_row">
  4. <u-col v-for="item in actionList" :key="item.idx" @click="actionClick(item)" span="3">
  5. <view class="action_item">
  6. <image :src="item.icon" alt="" srcset="" />
  7. <text class="action_item_title">{{ item.title }}</text>
  8. </view>
  9. </u-col>
  10. </u-row>
  11. </view>
  12. </template>
  13. <script>
  14. import { mapGetters, mapActions } from 'vuex';
  15. import { ChatingFooterActionTypes, ContactChooseTypes, PageEvents } from '../../../../../constant';
  16. import { AmapWebKey } from '../../../../../common/config';
  17. import IMSDK, { IMMethods } from 'openim-uniapp-polyfill';
  18. import { getPurePath } from '../../../../../util/common';
  19. import { callingModule } from '../../../../../util/imCommon';
  20. import { premissionCheck } from "@/js_sdk/wa-permission/permission.js"
  21. // import { gotoAppPermissionSetting,requestAndroidPermission } from "../../../../../util/permission";
  22. export default {
  23. components: {},
  24. data() {
  25. return {
  26. userID: '',
  27. isUser: false,
  28. readFilePermission:false,
  29. actionList: [
  30. {
  31. idx: 0,
  32. type: ChatingFooterActionTypes.takePhoto,
  33. title: '拍照',
  34. icon: require('../../../../../static/images/new/take_pictures_icon.png')
  35. },
  36. {
  37. idx: 1,
  38. type: ChatingFooterActionTypes.Album,
  39. title: '相册',
  40. icon: require('../../../../../static/images/new/album_icon.png')
  41. },
  42. {
  43. idx: 2,
  44. type: ChatingFooterActionTypes.Camera,
  45. title: '视频',
  46. icon: require('../../../../../static/images/new/video_icon.png')
  47. },
  48. {
  49. idx: 3,
  50. type: ChatingFooterActionTypes.pickCamera,
  51. title: '录像',
  52. icon: require('../../../../../static/images/new/picture_recording_icon.png')
  53. }
  54. ,{
  55. idx: 4,
  56. type: ChatingFooterActionTypes.Call,
  57. title: "语音通话",
  58. icon: require("../../../../../static/images/new/voice_call_icon.png"),
  59. },
  60. {
  61. idx: 5,
  62. type: ChatingFooterActionTypes.VideoCall,
  63. title: "视频通话",
  64. icon: require("../../../../../static/images/new/video_call_icon.png"),
  65. }
  66. //{
  67. // idx: 6,
  68. // type: ChatingFooterActionTypes.File,
  69. // title: "问诊订单",
  70. // icon: require("../../../../../static/images/chating_action_file.png"),
  71. // },
  72. // {
  73. // idx: 4,
  74. // type: ChatingFooterActionTypes.Card,
  75. // title: "名片",
  76. // icon: require("../../../../../static/images/chating_action_card.png"),
  77. // },
  78. // {
  79. // idx: 12,
  80. // type: ChatingFooterActionTypes.Location,
  81. // title: "位置",
  82. // icon: require("../../../../../static/images/chating_action_location.png"),
  83. // }
  84. ]
  85. };
  86. },
  87. computed: {
  88. ...mapGetters(['timStore']),
  89. imType() {
  90. return this.timStore?.imType ?? '';
  91. },
  92. orderId() {
  93. return this.timStore?.orderId ?? '';
  94. },
  95. orderType() {
  96. return this.timStore?.orderType ?? '';
  97. }
  98. },
  99. mounted() {
  100. let userID = this.$store.getters.storeCurrentConversation.userID;
  101. this.userID = userID.substring(1);
  102. this.isUser = userID.indexOf('U') != -1;
  103. if (this.$companyUserIsLogin() && this.isUser) {
  104. // this.actionList.push({
  105. // idx: 4,
  106. // type: ChatingFooterActionTypes.Call,
  107. // title: '语音通话',
  108. // icon: require('../../../../../static/images/audio-calling.svg')
  109. // });
  110. // this.actionList.push({
  111. // idx: 5,
  112. // type: ChatingFooterActionTypes.VideoCall,
  113. // title: '视频通话',
  114. // icon: require('../../../../../static/images/chating_action_call.png')
  115. // });
  116. this.actionList.push({
  117. idx: 6,
  118. type: ChatingFooterActionTypes.Order,
  119. title: '问诊订单',
  120. icon: require('../../../../../static/images/new/consultation_order_icon.png')
  121. });
  122. this.actionList.push({
  123. idx: 8,
  124. type: ChatingFooterActionTypes.StoreOrder,
  125. title: '药品订单',
  126. icon: require('../../../../../static/images/new/drug_orders_icon.png')
  127. });
  128. this.actionList.push({
  129. idx: 9,
  130. type: ChatingFooterActionTypes.Package,
  131. title: '疗法',
  132. icon: require('../../../../../static/images/new/therapy_icon.png')
  133. });
  134. this.actionList.push({
  135. idx: 10,
  136. type: ChatingFooterActionTypes.CouponPackage,
  137. title: '私域疗法券',
  138. icon: require('../../../../../static/images/new/therapy_voucher_icon.png')
  139. });
  140. this.actionList.push({
  141. idx: 11,
  142. type: ChatingFooterActionTypes.InquirySelect,
  143. title: '会诊',
  144. icon: require('../../../../../static/images/new/consultation_doctors_icon.png')
  145. });
  146. this.actionList.push({
  147. idx: 12,
  148. type: ChatingFooterActionTypes.Course,
  149. title: '课程',
  150. icon: require('../../../../../static/images/new/course_icon.png')
  151. });
  152. return;
  153. }
  154. //if((this.imType==1&&this.orderType==2)||this.imType==2){ //语音通话
  155. // this.actionList.push({
  156. // idx: 4,
  157. // type: ChatingFooterActionTypes.Call,
  158. // title: '语音通话',
  159. // icon: require('../../../../../static/images/audio-calling.svg')
  160. // });
  161. //}
  162. //if((this.imType==1&&this.orderType==2)||this.imType==2){ //视频通话
  163. // this.actionList.push({
  164. // idx: 5,
  165. // type: ChatingFooterActionTypes.VideoCall,
  166. // title: '视频通话',
  167. // icon: require('../../../../../static/images/chating_action_call.png')
  168. // });
  169. //}
  170. if (this.imType == 1) {
  171. //问诊订单
  172. this.actionList.push({
  173. idx: 6,
  174. type: ChatingFooterActionTypes.Order,
  175. title: '问诊订单',
  176. icon: require('../../../../../static/images/chating_action_file.png')
  177. });
  178. }
  179. if (this.imType == 2) {
  180. //视频通话
  181. this.actionList.push({
  182. idx: 7,
  183. type: ChatingFooterActionTypes.Follow,
  184. title: '随访单',
  185. icon: require('../../../../../static/images/chating_action_file.png')
  186. });
  187. this.actionList.push({
  188. idx: 8,
  189. type: ChatingFooterActionTypes.StoreOrder,
  190. title: '药品订单',
  191. icon: require('../../../../../static/images/chating_action_file.png')
  192. });
  193. }
  194. },
  195. methods: {
  196. async actionClick(action) {
  197. switch (action.type) {
  198. case ChatingFooterActionTypes.takePhoto:
  199. if (uni.$u.os() != 'ios') {
  200. this.requestPressmition();
  201. if(!this.readFilePermission){
  202. return;
  203. }
  204. }
  205. this.$emit('prepareMediaMessage', { type: ChatingFooterActionTypes.Camera, index: 0 });
  206. break;
  207. case ChatingFooterActionTypes.Album:
  208. if (uni.$u.os() != 'ios') {
  209. this.requestPressmition();
  210. if(!this.readFilePermission){
  211. return;
  212. }
  213. }
  214. this.$emit('prepareMediaMessage', { type: ChatingFooterActionTypes.Album, index: 0 });
  215. break;
  216. case ChatingFooterActionTypes.Camera:
  217. if (uni.$u.os() != 'ios') {
  218. this.requestPressmition();
  219. if(!this.readFilePermission){
  220. return;
  221. }
  222. }
  223. this.$emit('prepareMediaMessage', { type: ChatingFooterActionTypes.Album, index: 1 });
  224. break;
  225. case ChatingFooterActionTypes.pickCamera:
  226. if (uni.$u.os() != 'ios') {
  227. this.requestPressmition();
  228. if(!this.readFilePermission){
  229. return;
  230. }
  231. }
  232. this.$emit('prepareMediaMessage', { type: ChatingFooterActionTypes.Camera, index: 1 });
  233. break;
  234. case ChatingFooterActionTypes.Call:
  235. if (!this.$store.getters.storeCurrentConversation.groupID) {
  236. uni.$emit(PageEvents.RtcCall, 'audio');
  237. return;
  238. }
  239. IMSDK.asyncApi('signalingGetRoomByGroupID', IMSDK.uuid(), this.$store.getters.storeCurrentConversation.groupID).then(({ data }) => {
  240. if (data.invitation) {
  241. uni.showModal({
  242. title: '提示',
  243. content: '群通话进行中,是否直接加入?',
  244. confirmText: '确认',
  245. cancelText: '取消',
  246. success: (res) => {
  247. if (res.confirm) {
  248. callingModule.joinRoomLiveChat(data);
  249. }
  250. }
  251. });
  252. } else {
  253. uni.$emit(PageEvents.RtcCall, 'audio');
  254. }
  255. });
  256. break;
  257. case ChatingFooterActionTypes.VideoCall:
  258. if (!this.$store.getters.storeCurrentConversation.groupID) {
  259. uni.$emit(PageEvents.RtcCall, 'video');
  260. return;
  261. }
  262. IMSDK.asyncApi('signalingGetRoomByGroupID', IMSDK.uuid(), this.$store.getters.storeCurrentConversation.groupID).then(({ data }) => {
  263. if (data.invitation) {
  264. uni.showModal({
  265. title: '提示',
  266. content: '群通话进行中,是否直接加入?',
  267. confirmText: '确认',
  268. cancelText: '取消',
  269. success: (res) => {
  270. if (res.confirm) {
  271. callingModule.joinRoomLiveChat(data);
  272. }
  273. }
  274. });
  275. } else {
  276. uni.$emit(PageEvents.RtcCall, 'video');
  277. }
  278. });
  279. break;
  280. case ChatingFooterActionTypes.Order:
  281. {
  282. if (this.$companyUserIsLogin()) {
  283. uni.navigateTo({
  284. url: '/pages/company/inquiryOrderIMList?userId=' + this.userID
  285. });
  286. } else {
  287. uni.navigateTo({
  288. url: '/pages/store/inquiryOrderDetails?orderId=' + this.timStore.orderId
  289. });
  290. }
  291. }
  292. break;
  293. case ChatingFooterActionTypes.Follow:
  294. uni.navigateTo({
  295. url: '/pages/user/followDetails?followId=' + this.timStore.followId
  296. });
  297. break;
  298. case ChatingFooterActionTypes.StoreOrder:
  299. {
  300. if (this.$companyUserIsLogin()) {
  301. uni.navigateTo({
  302. url: '/pages/company/storeOrderList?userId=' + this.userID
  303. });
  304. } else {
  305. uni.navigateTo({
  306. url: '/pages/store/storeOrderDetail?orderId=' + this.timStore.orderId
  307. });
  308. }
  309. }
  310. break;
  311. case ChatingFooterActionTypes.Package: //疗法
  312. {
  313. if (this.$companyUserIsLogin()) {
  314. uni.navigateTo({
  315. url: '/pages/company/packageList?isIM=1'
  316. });
  317. }
  318. }
  319. break;
  320. case ChatingFooterActionTypes.CouponPackage:
  321. {
  322. if (this.$companyUserIsLogin()) {
  323. uni.navigateTo({
  324. url: '/pages/company/couponList?couponType=5&isIM=1'
  325. });
  326. }
  327. }
  328. break;
  329. case ChatingFooterActionTypes.InquirySelect:
  330. {
  331. if (this.$companyUserIsLogin()) {
  332. let companyId=uni.getStorageSync('companyId');
  333. let companyUserId=uni.getStorageSync('companyUserId');
  334. uni.navigateTo({
  335. url: '/pages/store/inquirySelectType?companyId='+companyId+'&companyUserId='+companyUserId+'&isIM=1'
  336. });
  337. }
  338. }
  339. break;
  340. case ChatingFooterActionTypes.Course:
  341. if (this.$companyUserIsLogin()) {
  342. uni.navigateTo({
  343. url: '/pages_im/pages/conversation/course/courseList?userId=' + this.userID
  344. });
  345. }
  346. break;
  347. case ChatingFooterActionTypes.Card:
  348. uni.navigateTo({
  349. url: `/pages_im/pages/common/contactChoose/index?type=${ContactChooseTypes.Card}`
  350. });
  351. break;
  352. case ChatingFooterActionTypes.File:
  353. if (uni.$u.os() != 'ios') {
  354. this.requestPressmition();
  355. if(!this.readFilePermission){
  356. return;
  357. }
  358. }
  359. IMSDK.pickFile().then(async (path) => {
  360. console.log(path);
  361. const idx = path.lastIndexOf('/');
  362. const fileName = path.slice(idx + 1);
  363. const message = await IMSDK.asyncApi(IMMethods.CreateFileMessageFromFullPath, IMSDK.uuid(), {
  364. filePath: getPurePath(path),
  365. fileName
  366. });
  367. this.$emit('sendMessage', message);
  368. });
  369. break;
  370. case ChatingFooterActionTypes.Location:
  371. uni.chooseLocation({
  372. success: async (res) => {
  373. if (res) {
  374. const options = {
  375. name: res.name,
  376. latng: `${res.latitude},${res.longitude}`,
  377. addr: res.address,
  378. city: res.address,
  379. module: 'locationPicker',
  380. latitude: res.latitude,
  381. longitude: res.longitude,
  382. url: `https://restapi.amap.com/v3/staticmap?size=600*300&markers=-1,https://cache.amap.com/lbs/static/cuntom_marker1.png,0:${res.longitude},${res.latitude}&key=${AmapWebKey}`
  383. };
  384. const message = await IMSDK.asyncApi(IMMethods.CreateLocationMessage, IMSDK.uuid(), {
  385. description: JSON.stringify(options),
  386. longitude: res.longitude,
  387. latitude: res.latitude
  388. });
  389. this.$emit('sendMessage', message);
  390. } else {
  391. uni.$u.toast('获取位置失败');
  392. }
  393. },
  394. fail: ({ errMsg }) => {
  395. if (!errMsg.includes('cancel')) {
  396. uni.$u.toast('获取位置失败');
  397. }
  398. }
  399. });
  400. break;
  401. default:
  402. break;
  403. }
  404. },
  405. async requestPressmition(){
  406. let result = await premissionCheck("EXTERNAL_STORAGE");
  407. console.log("premission result:"+result);
  408. if(result == 1) {
  409. this.readFilePermission=true;
  410. }
  411. }
  412. }
  413. };
  414. </script>
  415. <style lang="scss" scoped>
  416. .chat_action_bar {
  417. position: relative;
  418. background: #f0f2f6;
  419. padding: 24rpx 36rpx;
  420. .action_row {
  421. flex-wrap: wrap;
  422. margin-bottom: 24rpx;
  423. }
  424. .action_item {
  425. @include centerBox();
  426. flex-direction: column;
  427. margin-top: 28rpx;
  428. image {
  429. width: 58rpx;
  430. height: 58rpx;
  431. background-color: #fff;
  432. border-radius: 28rpx;
  433. padding:28rpx;
  434. }
  435. &_title {
  436. font-size: 24rpx;
  437. color: #999;
  438. margin-top: 16rpx;
  439. }
  440. }
  441. }
  442. </style>