ChatingActionBar.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="chat_action_bar">
  3. <view class="action_row">
  4. <view
  5. class="action_item"
  6. v-for="item in actionList"
  7. :key="item.idx"
  8. @click="actionClick(item)"
  9. >
  10. <image :src="item.icon" alt="" srcset="" />
  11. <text class="action_item_title">{{ item.title }}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { mapGetters, mapActions } from 'vuex';
  18. import {ChatingFooterActionTypes,ContactChooseTypes,PageEvents} from "../../../../../constant";
  19. import { AmapWebKey } from "../../../../../common/config";
  20. import IMSDK, { IMMethods } from "openim-uniapp-polyfill";
  21. import { getPurePath } from "../../../../../util/common";
  22. import { callingModule } from "../../../../../util/imCommon";
  23. // import { gotoAppPermissionSetting,requestAndroidPermission } from "../../../../../util/permission";
  24. export default {
  25. components: {},
  26. data() {
  27. return {
  28. actionList: [
  29. {
  30. idx: 0,
  31. type: ChatingFooterActionTypes.takePhoto,
  32. title: "拍照",
  33. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_camera.png",
  34. },
  35. {
  36. idx: 1,
  37. type: ChatingFooterActionTypes.Album,
  38. title: "相册",
  39. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_image.png",
  40. },
  41. {
  42. idx: 2,
  43. type: ChatingFooterActionTypes.Camera,
  44. title: "视频",
  45. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/take-photo.svg",
  46. },
  47. {
  48. idx: 3,
  49. type: ChatingFooterActionTypes.pickCamera,
  50. title: "录像",
  51. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/take-video.svg",
  52. }
  53. // ,{
  54. // idx: 4,
  55. // type: ChatingFooterActionTypes.Call,
  56. // title: "语音通话",
  57. // icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/audio-calling.svg",
  58. // },
  59. // {
  60. // idx: 5,
  61. // type: ChatingFooterActionTypes.VideoCall,
  62. // title: "视频通话",
  63. // icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_call.png",
  64. // },
  65. // {
  66. // idx: 6,
  67. // type: ChatingFooterActionTypes.File,
  68. // title: "问诊订单",
  69. // icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_file.png",
  70. // },
  71. // {
  72. // idx: 4,
  73. // type: ChatingFooterActionTypes.Card,
  74. // title: "名片",
  75. // icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_card.png",
  76. // },
  77. // {
  78. // idx: 5,
  79. // type: ChatingFooterActionTypes.Location,
  80. // title: "位置",
  81. // icon:"https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_location.png",
  82. // },
  83. ],
  84. };
  85. },
  86. computed: {
  87. ...mapGetters(["timStore"]),
  88. imType() {
  89. return this.timStore?.imType ?? '' ;
  90. },
  91. orderId() {
  92. return this.timStore?.orderId ?? '' ;
  93. },
  94. orderType() {
  95. return this.timStore?.orderType ?? '' ;
  96. }
  97. },
  98. mounted() {
  99. // if((this.imType==1&&this.orderType==2)||this.imType==2){ //语音通话
  100. // this.actionList.push({
  101. // idx: 4,
  102. // type: ChatingFooterActionTypes.Call,
  103. // title: "语音通话",
  104. // icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/audio-calling.svg"
  105. // });
  106. // }
  107. // if((this.imType==1&&this.orderType==2)||this.imType==2){ //视频通话
  108. // this.actionList.push({
  109. // idx: 5,
  110. // type: ChatingFooterActionTypes.VideoCall,
  111. // title: "视频通话",
  112. // icon: requirestatic/images/chating_action_call.png")
  113. // });
  114. // }
  115. if(this.imType==1){ //问诊订单
  116. this.actionList.push({
  117. idx: 6,
  118. type: ChatingFooterActionTypes.Order,
  119. title: "问诊订单",
  120. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_file.png"
  121. });
  122. }
  123. if(this.imType==2){ //视频通话
  124. this.actionList.push({
  125. idx: 7,
  126. type: ChatingFooterActionTypes.Follow,
  127. title: "随访单",
  128. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_file.png"
  129. });
  130. this.actionList.push({
  131. idx: 8,
  132. type: ChatingFooterActionTypes.StoreOrder,
  133. title: "药品订单",
  134. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_action_file.png"
  135. });
  136. }
  137. },
  138. methods: {
  139. async actionClick(action) {
  140. switch (action.type) {
  141. case ChatingFooterActionTypes.takePhoto:
  142. this.$emit("prepareMediaMessage", {type:ChatingFooterActionTypes.Camera,index:0 });
  143. break;
  144. case ChatingFooterActionTypes.Album:
  145. this.$emit("prepareMediaMessage", {type:ChatingFooterActionTypes.Album,index:0});
  146. break;
  147. case ChatingFooterActionTypes.Camera:
  148. this.$emit("prepareMediaMessage", {type:ChatingFooterActionTypes.Album,index:1});
  149. break;
  150. case ChatingFooterActionTypes.pickCamera:
  151. this.$emit("prepareMediaMessage", {type:ChatingFooterActionTypes.Camera,index:1});
  152. break;
  153. case ChatingFooterActionTypes.Call:
  154. if (!this.$store.getters.storeCurrentConversation.groupID) {
  155. uni.$emit(PageEvents.RtcCall,"audio");
  156. return;
  157. }
  158. IMSDK.asyncApi(
  159. "signalingGetRoomByGroupID",
  160. IMSDK.uuid(),
  161. this.$store.getters.storeCurrentConversation.groupID
  162. ).then(({ data }) => {
  163. if (data.invitation) {
  164. uni.showModal({
  165. title: "提示",
  166. content: "群通话进行中,是否直接加入?",
  167. confirmText: "确认",
  168. cancelText: "取消",
  169. success: (res) => {
  170. if (res.confirm) {
  171. callingModule.joinRoomLiveChat(data);
  172. }
  173. }
  174. });
  175. } else {
  176. uni.$emit(PageEvents.RtcCall,"audio");
  177. }
  178. });
  179. break;
  180. case ChatingFooterActionTypes.VideoCall:
  181. if (!this.$store.getters.storeCurrentConversation.groupID) {
  182. uni.$emit(PageEvents.RtcCall,"video");
  183. return;
  184. }
  185. IMSDK.asyncApi(
  186. "signalingGetRoomByGroupID",
  187. IMSDK.uuid(),
  188. this.$store.getters.storeCurrentConversation.groupID
  189. ).then(({ data }) => {
  190. if (data.invitation) {
  191. uni.showModal({
  192. title: "提示",
  193. content: "群通话进行中,是否直接加入?",
  194. confirmText: "确认",
  195. cancelText: "取消",
  196. success: (res) => {
  197. if (res.confirm) {
  198. callingModule.joinRoomLiveChat(data);
  199. }
  200. }
  201. });
  202. } else {
  203. uni.$emit(PageEvents.RtcCall,"video");
  204. }
  205. });
  206. break;
  207. case ChatingFooterActionTypes.Order:
  208. uni.navigateTo({
  209. url: '/pages_order/inquiryOrderDetails?orderId='+this.timStore.orderId
  210. });
  211. break;
  212. case ChatingFooterActionTypes.Follow:
  213. uni.navigateTo({
  214. url: '/pages_user/followDetails?orderId='+this.timStore.followId
  215. });
  216. break;
  217. case ChatingFooterActionTypes.StoreOrder:
  218. uni.navigateTo({
  219. url: '/pages_order/storeOrderDetail?orderId='+this.timStore.orderId
  220. });
  221. break;
  222. case ChatingFooterActionTypes.Card:
  223. uni.navigateTo({
  224. url: `/pages_im/pages/common/contactChoose/index?type=${ContactChooseTypes.Card}`,
  225. });
  226. break;
  227. case ChatingFooterActionTypes.File:
  228. IMSDK.pickFile().then(async (path) => {
  229. console.log(path);
  230. const idx = path.lastIndexOf("/");
  231. const fileName = path.slice(idx + 1);
  232. const message = await IMSDK.asyncApi(
  233. IMMethods.CreateFileMessageFromFullPath,
  234. IMSDK.uuid(),
  235. {
  236. filePath: getPurePath(path),
  237. fileName,
  238. },
  239. );
  240. this.$emit("sendMessage", message);
  241. });
  242. break;
  243. case ChatingFooterActionTypes.Location:
  244. uni.chooseLocation({
  245. success: async (res) => {
  246. if (res) {
  247. const options = {
  248. name: res.name,
  249. latng: `${res.latitude},${res.longitude}`,
  250. addr: res.address,
  251. city: res.address,
  252. module: "locationPicker",
  253. latitude: res.latitude,
  254. longitude: res.longitude,
  255. 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}`,
  256. };
  257. const message = await IMSDK.asyncApi(
  258. IMMethods.CreateLocationMessage,
  259. IMSDK.uuid(),
  260. {
  261. description: JSON.stringify(options),
  262. longitude: res.longitude,
  263. latitude: res.latitude,
  264. },
  265. );
  266. this.$emit("sendMessage", message);
  267. } else {
  268. uni.$u.toast("获取位置失败");
  269. }
  270. },
  271. fail: ({ errMsg }) => {
  272. if (!errMsg.includes("cancel")) {
  273. uni.$u.toast("获取位置失败");
  274. }
  275. },
  276. });
  277. break;
  278. default:
  279. break;
  280. }
  281. },
  282. },
  283. };
  284. </script>
  285. <style lang="scss" scoped>
  286. .chat_action_bar {
  287. position: relative;
  288. background: #f0f2f6;
  289. padding: 24rpx 36rpx;
  290. .action_row {
  291. display: flex;
  292. align-items: center;
  293. justify-content: flex-start;
  294. flex-wrap: wrap;
  295. margin-bottom: 24rpx;
  296. }
  297. .action_item {
  298. @include centerBox();
  299. flex-direction: column;
  300. margin-top: 24rpx;
  301. width: 25%;
  302. image {
  303. width: 96rpx;
  304. height: 96rpx;
  305. }
  306. &_title {
  307. font-size: 24rpx;
  308. color: #999;
  309. margin-top: 6rpx;
  310. }
  311. }
  312. }
  313. </style>